Relatively new to Ruby on Rails, i'm currently getting this routing
error I get after going to:- http://localhost:3000/licenses :-

No route matches {:controller=>"licenses", :action=>"csv_import"}

My current routes.rb file:-

Inventory::Application.routes.draw do
root :to => "home#index"

ActiveAdmin.routes(self)

devise_for :admin_users, ActiveAdmin::Devise.config

resources :licenses
end

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Walter Lee Davis at Nov 28, 2011 at 4:15 pm

    On Nov 28, 2011, at 10:52 AM, Derrick Bailey wrote:

    Relatively new to Ruby on Rails, i'm currently getting this routing
    error I get after going to:- http://localhost:3000/licenses :-

    No route matches {:controller=>"licenses", :action=>"csv_import"}

    My current routes.rb file:-

    Inventory::Application.routes.draw do
    root :to => "home#index"

    ActiveAdmin.routes(self)

    devise_for :admin_users, ActiveAdmin::Devise.config

    resources :licenses
    end
    Try this:

    resources :licenses do
    collection do
    post 'csv_import'
    end
    end

    That's off the top of my head, but it should help. resources :licenses just gets you the 7 RESTful actions, anything else you need to add yourself, or use a wildcard map (haven't seen one of those in quite a while).

    Walter
    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Derrick Bailey at Nov 28, 2011 at 4:56 pm

    Walter Davis wrote in post #1034132:
    On Nov 28, 2011, at 10:52 AM, Derrick Bailey wrote:

    ActiveAdmin.routes(self)

    devise_for :admin_users, ActiveAdmin::Devise.config

    resources :licenses
    end
    Try this:

    resources :licenses do
    collection do
    post 'csv_import'
    end
    end

    That's off the top of my head, but it should help. resources :licenses
    just gets you the 7 RESTful actions, anything else you need to add
    yourself, or use a wildcard map (haven't seen one of those in quite a
    while).

    Walter
    Thanks this has fixed the problem, but index.html.erb doesn't display my
    import csv file button, the code i have in index.html.erb:-

    <h1>Listing licenses</h1>

    <table>
    <tr>
    <th>App</th>
    <th>Serial</th>
    <th>User</th>
    <th>Notes</th>
    <th></th>
    <th></th>
    <th></th>
    </tr>

    <% @licenses.each do |license| %>
    <tr>
    <td><%= license.app %></td>
    <td><%= license.serial %></td>
    <td><%= license.user %></td>
    <td><%= license.notes %></td>
    <td><%= link_to 'Show', license %></td>
    <td><%= link_to 'Edit', edit_license_path(license) %></td>
    <td><%= link_to 'Destroy', license, confirm: 'Are you sure?',
    method: :delete %></td>
    </tr>
    <% end %>
    </table>

    <% form_for :dump, :url=>{:controller=>"licenses",
    :action=>"csv_import"}, :html => { :multipart => true } do |f| -%>
    <table">
    <tr>
    <td>
    <label for="dump_file">
    Select a CSV File :
    </label>
    </td>
    <td >
    <%= f.file_field :file -%>
    </td>
    </tr>
    <tr>
    <td colspan='2'>
    <%= submit_tag 'Submit' -%>
    </td>
    </tr>
    </table>
    <% end -%>


    <br />

    <%= link_to 'New License', new_license_path %>

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Nov 28, 2011 at 5:08 pm

    On 28 November 2011 16:56, Derrick Bailey wrote:
    Walter Davis wrote in post #1034132:
    On Nov 28, 2011, at 10:52 AM, Derrick Bailey wrote:

    ActiveAdmin.routes(self)

    devise_for :admin_users, ActiveAdmin::Devise.config

    resources :licenses
    end
    Try this:

    resources :licenses do
    collection do
    post 'csv_import'
    end
    end

    That's off the top of my head, but it should help. resources :licenses
    just gets you the 7 RESTful actions, anything else you need to add
    yourself, or use a wildcard map (haven't seen one of those in quite a
    while).

    Walter
    Thanks this has fixed the problem, but index.html.erb doesn't display my
    import csv file button, the code i have in index.html.erb:-
    I suggest starting a new thread for this as it is nothing to do with
    the subject line. In the meantime have a look at the generated html
    (View > Page Source or similar in the browser) and see whether your
    erb is generating the correct html.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Nov 28, 2011 at 4:23 pm

    On 28 November 2011 15:52, Derrick Bailey wrote:
    Relatively new to Ruby on Rails, i'm currently getting this routing
    error I get after going to:- http://localhost:3000/licenses :-

    No route matches {:controller=>"licenses", :action=>"csv_import"}

    My current routes.rb file:-

    Inventory::Application.routes.draw do
    root :to => "home#index"

    ActiveAdmin.routes(self)

    devise_for :admin_users, ActiveAdmin::Devise.config

    resources :licenses
    If you make this
    resource :licenses do
    member do
    get 'csv_import'
    end
    end

    That will add the action csv_import as a GET operation to the routes.
    It may well be that you don't want it to be a GET however, but that is
    a different issue.

    See the Rails Guide on routing for more information.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 28, '11 at 3:53p
activeNov 28, '11 at 5:08p
posts5
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase