Instead of adding teams one-by-one, I’m trying to create a form to enter a bunch of comma-separated team names all at once. In my routes.rb, I have
map.connect '/teams/massentry', :controller => 'teams', :action => 'massentry'
map.resources :teams
In teams_controller.rb, I have
def massentry
@team = Team.new
end
That’s not what that will look like when I’m done. I just stuck it in there so there would be something. Finally, I have /views/teams/massentry.html.erb
<% form_tag({:controller => "teams", :action => "massentry"}, :method => 'get') do %>
<p>
<%= label_tag(:t, "CSV List of Teams" %>
<%= text_area_tag(:t, "", :size => "24x6") %>
</p>
<p><%= submit_tag("Submit") %></p>
<% end %>
I don’t know if that form is right and obviously don’t have any of the logic written, but I just wanted to see what it looks like. If I go to
http://localhost:3000/teams/massentry
It returns Couldn’t find team with id=massentry. It’s executing the show method, but I thought if I put the map.connect before the resource line in routes.rb it would redirect. Using rails 2.3.8
Rails routes are evaluated in the order they appear. So you can either leave it the way you just described (your custom route first) or you can do it in a RESTful way like @numbers1311407 said. Also, it makes more sense to use :post instead of :get.