Skip to content

Instantly share code, notes, and snippets.

@jbgutierrez
Created October 20, 2009 22:14
Show Gist options
  • Save jbgutierrez/214669 to your computer and use it in GitHub Desktop.
Save jbgutierrez/214669 to your computer and use it in GitHub Desktop.
RAILS SHELL APPLICATION IN 10 STEPS
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