Elizabeth Buckwalter
Elizabeth Buckwalter

Reputation: 968

active_scaffold routing error

If you haven't seen my question yesterday, this is my second rails app. The first went nice and smooth, but this one keeps giving me one random error after another. I installed active_scaffold for this app as well as the last app (the first error, instead of using script/install plugin git://active_scaffold repository, I did script/install plugin http://active_scaffold repository.) I didn't want to spell out basic CRUD on minor models. After the install problems, (before I found the http solution from a windows user when I'm on Linux) I thought I'd try out Hobo. Well, Hobo updated actionmailer, actionpack, activerecord, activeresource, and installed rack. Rails isn't even using the updated versions. But as you can see at the bottom of the trace it's using rack. I have a feeling it has something to do with my futzing around with installing Hobo which I uninstalled. Thanks in advance.

[Edit]
I had asked the question over at the ActiveScaffold Group the answer (if you don't want to follow the link) was that this line needed to be added to routes:

map.resources :modelName, :active_scaffold => true

It doesn't entirely answer my question, since the documentation said nothing about changing routes. But, it works.

[/Edit]

ActionController::RoutingError in Departments#index

Showing vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb where line #8 raised:

No route matches {:_method=>:get, :action=>"show_search", :controller=>"departments"}

Extracted source (around line #8):

5:       <% next if controller.respond_to? link.security_method and !controller.send(link.security_method) -%>
6:    <% next if link.action == 'new' && params[:nested].nil? && active_scaffold_config.list.always_show_create %>
7:    <% next if link.action == 'show_search' && active_scaffold_config.list.always_show_search %>
8:       <%= render_action_link(link, new_params) -%>
9:     <% end -%>
10: 
11:     <%= loading_indicator_tag(:action => :table) %>

Trace of template inclusion: vendor/plugins/active_scaffold/frontends/default/views/list.html.erb

Full Trace It was taking forever to format it. I'm still not fully conversant in SO's formatting (sometimes the server is down. reboots are reinstalls. it's a play server)

Upvotes: 4

Views: 1426

Answers (3)

Bret Weinraub
Bret Weinraub

Reputation: 2283

For Rails 4+ at least, your entry in config/routes.rb should look like:

resources :models do # my model name in plural
  as_routes
  # for action links of type member, add the following
  # see also [note, via the action-link API, you can change the HTTP verb.  Adjust this route accordingly.
  # https://github.com/activescaffold/active_scaffold/wiki/Adding-custom-actions
  # get :my_custom_action, :on => :member
end

Note, getting the right version of the Gem requires the following config in your Gemfile:

 gem 'active_scaffold', github: 'activescaffold/active_scaffold', :branch => "3-4-stable"

If you get an error that "as_routes" isn't found; that'd be the problem.

THIS IS RAILS 4 ONLY

Upvotes: 2

Sharjeel
Sharjeel

Reputation: 15798

For Rails 5.x you can set route as follow:

resources :model, concerns: :active_scaffold

Upvotes: 0

Elizabeth Buckwalter
Elizabeth Buckwalter

Reputation: 968

Add this to routes:

map.resources :modelName, :active_scaffold => true

And, contrary to my edit, it is in the documentation. It's in the wiki at Github. My second question at SO, and I could have found the answer by RTFM'ing. <sigh>

Upvotes: 5

Related Questions