Installation on a Mac
I did try the following, but I think actually you can go straight to the tutorial and follow the steps there.
- Download the latest zip file
- Unpack into a directory and move into your directory
- Open a Terminal
- cd from your home directory into the new directory (cd rubygems-1.3.X/)
- run: sudo ruby setup.rb
It appears that Ruby on Rails has changed a lot between versions. So starting the server was harder than the Internet said it would be (as script/server approach has become defunct). So I spent some time getting confused by online tutorials, such as Apple. Installing XCode from the Apple Developer Center however was useful.
I have found much more joy by following the tutorial at http://guides.rubyonrails.org/getting_started.html and a basics tutorial. Oh and my good friend jcn helped explain some stuff too.
Creating a Basic Form
Next I wanted to create a basic HTML Form where the Controller catches and processes the results. I got most of what I needed from an online answer. However I needed to know that creating the controller is done at command line using
rails generate controller Searches
and then place in the following code.
ss SearchesController < ActionController::Base
lookup = params[:lookup]
@models = Model.find_by_lookup(lookup)
And place in the following code for the view.
<% form_tag searches_path do %>
<%= text_field_tag :lookup %>
<%= submit_tag "Submit" %>
<% end %>
But the stumbling block for me was linking the View to Controller by placing the following in the config/routes.rb file