Ruby develoment:
To create new application , install ruby and gem and webrick from apt with this command
sudo gem install rails
install sqlite3 and its dev file from apt.
then create a sample application,
rails create blog
cd blog
rails server
Here rails generate controller home index
To edit configuration go to
app/views/home/index.html.erb
give this command:
rm public/index.html
Now, you have to tell Rails where your actual home page is located. Open the file config/routes.rb in your editor. This is your application’s routing file which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with :root to, uncomment it and change it like the following:
Blog::Application.routes.draw do #... # You can have the root of your site routed with "root" # just remember to delete public/index.html. root :to => "home#index"
The root :to => "home#index" tells Rails to map the root action to the home controller’s index action.
Now if you navigate to http://localhost:3000 in your browser, you’ll see Hello, Rails!.
For routing add get part
Blog::Application.routes.draw do
get "say/hello"
get "say/goodbye"
get "home/index" receive
No comments:
Post a Comment