Created
January 12, 2010 21:50
-
-
Save coderberry/275657 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RAILS SHELL APPLICATION IN 10 STEPS !!! | |
1.- rails shell -d mysql | |
2.- cd shell | |
3.- Edit config/database.yml | |
4.- rake db:create | |
5.- ruby script\generate scaffold Command execute:string | |
6.- rake db:migrate | |
7.- Delete public/index.html | |
8.- Edit config/routes.rb | |
map.resources :commands | |
map.root :controller => "commands" | |
9.- Edit the app/controllers/commands_controller.rb and add the @command_result variable in the show method. | |
def show | |
@command = Command.find(params[:id]) | |
@command_result = %x[#{@command.execute.to_s}] | |
This is where we retrieve the @command.execute previously saved and execute it in the Rails server. | |
10.- Update the app/views/commands/show.html.erb | |
<pre> | |
<%=h @command_result %> | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment