views:

36

answers:

1

So.. here is my link_to

  • <%= link_to "Archive", :action => 'archive' %>
  • and my output in the console

     Parameters: {"action"=>"archive", "controller"=>"achievables"}
    

    why is the action not "archive" ? the method is defined in the controller... spelled correctly and everything.

    EDIT: from routes.rb

      map.archives 'achievable/archive', :controller => 'achievables', :action => 'archive'
    
      map.resources :achievables, :member => {:build => [:get,:post], :publish_detail => [:get,:post], :publish=>[:get,:post], :confirm_publish=>[:get,:post], :confirm_delete=>[:get,:post]}
    

    right now, the error is

    Showing app/views/layouts/build_archivable.html.erb where line #6 raised:
    
    Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
    

    which, again, is the wrong path. =\

    +1  A: 

    Try specifying the action as a string rather than a symbol:

    <%= link_to 'Archive', :action => 'archive' %>
    

    Alternatively, you might have a higher priority route defined within config/routes.rb that is getting matched before the default /:controller/:action/:id route (Rails starts at the top of the file and works downwards until to hits a route that matches the URL).

    John Topley
    how would you override that kind of routing?
    DerNalia
    @DerNalia Edit your question to show us the contents of your routes file and then I can tell you if that's the case or not.
    John Topley
    done. I only added what I think in relevant. the routes file is 100 lines. and could be more if I had a say in the formatting.
    DerNalia
    got it, I next had to specify to use the application layout for some reason.
    DerNalia
    So is it going into the `archive` action or is it going into the `show` action? It's not clear since you edited your question.
    John Topley
    It was going to the archive action, but was using a layout completely not related to my view, which is why I though it was going to the build action... (It really did go to show in my original)... So, I forced it to use the default layout (specified in the archive action)
    DerNalia