I'm new to rails and I'm currently using 2.3.8. I'm designing a web service for an iOS app.
As I'm normally a client side iPhone developer, my knowledge of server side implementation is shamefully minimal.
The problem I'm having is that I'm trying to pass some params in a GET request to the index action in one of my controllers. This is routed using the default
map.resources :dishes
where dishes is the name of the controller, created with scaffold.
I would like to pass multiple params to either a new action or to the index, which will allow me to filter the dish objects to return.
The index method looks like
def index
if(params[:latitude])
#min = 0.5 - 1
#max = 0.5 + 1
#locations = Location.find(:all, :conditions => [":latitude > ? AND :latitude < ?", #min, #max])
#dishes = new Array
#locations.each do |loc|
#dishes = #dishes + loc.dishes
end
respond_to do |format|
format.html # index.html.erb
format.json {render :json => #dishes.to_json(:except => [ :user_id, :location_id , :like_id], :include => { :user => { :only => [:id, :name] } } ) }
end
else
#dishes = Dish.all
respond_to do |format|
format.html # index.html.erb
format.json {render :json => #dishes.to_json(:except => [ :user_id, :location_id , :like_id], :include => { :user => { :only => [:id, :name] } } ) }
end
end
end
I am currently getting the following error when I pass in an extra param
ArgumentError in DishesController#index
wrong number of arguments (1 for 0)
The full error:
ArgumentError in DishesController#index
wrong number of arguments (1 for 0)
RAILS_ROOT: /Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5
Application Trace | Framework Trace | Full Trace
/Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in `new'
/Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in `index'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport- 2.3.8/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:606:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:438:in `call'
Request
Parameters:
{"format"=>"json",
"latitude"=>"0.5"}
Show session dump
Response
Headers:
{"Content-Type"=>"",
"Cache-Control"=>"no-cache"}
I realise this goes slightly against the RESTful design of Rails but I couldn't work out another way to do it.
Again, I'm a new to rails / web service dev so if you have any tips I would welcome them.
Thanks.
You have
#dishes = new Array
which is not Ruby unfortunately :) There are three ways to create an instance of Array
#dishes = Array.new
#dishes = []
#dishes = Array( nil )
also pay attention to
/Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in 'new'
/Users/jon/Documents/Dev/Research/FF5_Rails_Test/FF5/app/controllers/dishes_controller.rb:9:in 'index'
which tells you that error happened in new not in index
Related
Originally from here, i'm posting a new thread to focus on my issue resolving around the "to_xml" method.
What i'm trying to do : make a conversion from a ruby Object (Whois::Record) to XML.
I am currently using ActiveModel but not ActiveRecord (eg previous thread for reasons)
Here is the relevant controller :
def lookup
domain = params[:domain]
#whois = Request.new
#whois.search(domain)
respond_to do |format|
if #whois != nil
format.html
format.json {render :json => #whois.body}
format.xml {render :xml => #whois}
else
format.html { render :new }
format.json { render json: #request.errors, status: :unprocessable_entity }
end
end
end
Please note that #whois is NOT a Whois::Record object, but a class that contains such object (in the body property)
And the view :
<% if #whois != nil %>
<%= #whois %>
<!--JSON-->
<%= #whois.body.to_json %>
<!--XML-->
<% byebug %>
<%= #whois.to_xml %>
<% end %>
Note that the to_json method works fine, so the fact that ruby throws a nilClass exception is quite weird.
Here is the stacktrace starting from to_xml :
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/xml_mini.rb:148:in _dasherize'
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/xml_mini.rb:140:inrename_key'
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/xml_mini.rb:119:in to_tag'
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/core_ext/hash/conversions.rb:88:inblock (2 levels) in to_xml'
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/core_ext/hash/conversions.rb:88:in each'
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/core_ext/hash/conversions.rb:88:inblock in to_xml'
/home/nico/.rvmruby (2.1.3) gems/builder-3.2.2/lib/builder/xmlbase.rb:175:in call'
/home/nico/.rvmruby (2.1.3) gems/builder-3.2.2/lib/builder/xmlbase.rb:175:in_nested_structures'
/home/nico/.rvmruby (2.1.3) gems/builder-3.2.2/lib/builder/xmlbase.rb:68:in tag!'
/home/nico/.rvmruby (2.1.3) gems/activesupport-4.1.6/lib/active_support/core_ext/hash/conversions.rb:87:into_xml'
app/models/request.rb:26:in `to_xml'
Byebug gives me a lead as such :
to_xml > ActiveSupport::SafeBuffer::OutpuBuffer#safe_concat
153: def safe_concat(value)
=> 154: raise SafeConcatError unless html_safe?
155: original_concat(value)
156: end
note : html_safe? is set at 'true' here, and value equals "\t"
original_concat
File activesupport/lib/active_support/core_ext/string/output_safety.rb, line 132
Alias to original_concat
def concat(value)
if !html_safe? || value.html_safe?
super(value)
else
super(ERB::Util.h(value))
end
end
And when i step over i come back to the to_xml method, that's throwing a tantrum about not having a class to call upon methhods. I would be grateful for any help, thanks.
Edit
Here is the class Request from my model :
#This is a generic class for checking Key authenticity and sending requests to the engine
#Furthermore, this class will contain the WHOIS response in body
include ActiveModel::Model
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
attr_accessor :body
def attributes
{body => nil}
end
def to_xml(options = {})
to_xml_opts = {:skip_types => true} # no type information, not such a great idea!
to_xml_opts.merge!(options.slice(:builder, :skip_instruct))
# a builder instance is provided when to_xml is called on a collection of instructors,
# in which case you would not want to have <?xml ...?> added to each item
to_xml_opts[:root] ||= "instructor"
self.attributes.to_xml(to_xml_opts)
end
def search(domain)
# since rails compiles the code before executing a search once,
# we have to catch niClass exceptions and such
if domain != ( nil && true && "" )
c = Whois::Client.new
self.body = c.lookup(domain)
end
end
I've used this as from what i've understood XML tries to define a type for each attribute, and has problems with named objects. Here's the thread about to_xml and objects in rails
I found a lot of questions with same title but could not found the appropriate answer.
I am testing a controller
Player Controller
def create
player = Player.create(params[':player'])
if player.valid?
# if creation successful, log the player in:
player_session = PlayerSession.create(
player: player,
session_token: ActiveSupport::SecureRandom.urlsafe_base64
)
render json: {session_token: player_session.session_token}
else
render json: {error: "Player name already exists."}, status: :unprocessable_entity
end
end
Player Controller Test
test "create" do
post(:create,
{
'player' => {
'player_name' => "usman",
'password' => 123,
'email' => 'ranasaani#gmail.com'
}
}
)
assert_select response.body
end
while executing the test file the following errors display on console.
ActionController::RoutingError: No route matches {:player=>{"player_name"=>"usman", "password"=>123, "email"=>"ranasaani#gmail.com"}, :controller=>"pl
ayers", :action=>"create"}
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:406:in `generate'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:453:in `generate'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:449:in `generate_extras'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:445:in `extra_keys'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_controller/test_case.rb:143:in `assign_parameters'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_controller/test_case.rb:402:in `process'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_controller/test_case.rb:47:in `process'
D:/jruby-1.7.1/lib/ruby/gems/shared/gems/actionpack-3.0.3/lib/action_controller/test_case.rb:355:in `post'
D:/Projects/lyricle/test/functional/players_controller_test.rb:5:in `test_create'
org/jruby/RubyBasicObject.java:1659:in `__send__'
why this error is here?
You have to define routes if you want anything to be able to access your controller.
So, in your config/routes.rb :
App::Application.routes.draw do
resources :your_resource_plural_name
end
The create action should be like this:
def create
#player = Player.new(params[:player])
#your code
end
also you need to add new action before create action:
def new
#player = Player.new
end
in routes.rb you should have resources :players
#player is an instance variable to make you able to call it in the view also.
See Rails Guide to create your first application.
Also check Rails for Zombies they are very good
I have installed the rails3-jquery-autocomplete gem and its shownin the list of gems.
I have generated the autocomplete-rails.js file and included it in my layout.
I am trying to implement auto complete field for the users table on the names field.
I am getting an error saying
"undefined local variable or method `autocomplete' for #<#<Class:0xb709ac24>:0xb7099a7c>"
Please let me know where I had went wrong.
releases_controller.rb
class ReleasesController < AuthorizedController
# GET /releases
# GET /releases.xml
autocomplete :users, :name
def new
#release = Release.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => #release }
end
end
My view file:
= form.autocomplete_field_tag 'tester_name', :data-autocomplete=>"releases_autocomplete_users_name_path"
my routes file:
get 'releases/autocomplete_users_name'
Error:
ActionView::Template::Error (undefined local variable or method `autocomplete' for #<#<Class:0xb71cc1d8>:0xb71caa90>):
37: -puts "testers=#{#testers}"
38: = form.label :tester_tokens, "Testers"
39: = form.text_field :tester_tokens
40: = autocomplete_field_tag 'tester_name', :data-autocomplete=>"releases_autocomplete_users_name_path"
41: - #testers.each do |tester|
42: %tr
43: %td=tester.name
please update your route file this may be help you, as it is working for me:
resources :releases do
get :autocomplete_user_name, :on => :collection
end
chears..
Maybe don't use tag, as in the rails3-jquery-autocomplete page.
try
form.autocomplete_field :tester_name, autocomplete_tester_name_releases_path
I think you should also create a virtual field on releases model if you want to use :tester_name.
if you want to grab the id, then you can create a hidden field and add :id_element => '#some_element' to the autocomplete helper
In Rails 2.3.x, you can override render_optional_error_file like so:
# ApplicationController.rb
protected
def render_optional_error_file(status_code)
render :template => "errors/500", :status => 500, :layout => 'application'
end
However, Rails 3 no longer has render_optional_error_file. Instead, you need to override rescue_action_in_public, which you can do like so:
# config/initializers/error_page.rb
module ActionDispatch
class ShowExceptions
protected
def rescue_action_in_public(exception)
status = status_code(exception).to_s
template = ActionView::Base.new(["#{Rails.root}/app/views"])
if ["404"].include?(status)
file = "/errors/404.html.erb"
else
file = "/errors/500.html.erb"
end
body = template.render(:file => file)
render(status, body)
end
end
end
This works, but does not use the application's layout. However, if you specify the layout path like so:
body = template.render(:file => file, :layout => "layouts/application") # line 15
You get an Error during failsafe response: ActionView::Template::Error.
Line 4 of application.html.erb:4 is:
<%= stylesheet_link_tag "app", "jquery-ui", "jquery.fancybox", :cache => "all" %>
Whatever ActionView normally uses to render templates isn't getting loaded.
The stack trace is:
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:794:in `join'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:794:in `rails_asset_id'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:817:in `rewrite_asset_path'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:746:in `compute_public_path'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:424:in `path_to_stylesheet'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:875:in `ensure_stylesheet_sources!'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:874:in `each'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:874:in `ensure_stylesheet_sources!'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/helpers/asset_tag_helper.rb:512:in `stylesheet_link_tag'
/data/sites/fundraisers-stage/releases/20110316194843/app/views/layouts/application.html.erb:4:in `_app_views_layouts_application_html_erb___19482063_70294907435920_0'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/template.rb:135:in `send'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/template.rb:135:in `render'
/var/lib/gems/1.8/gems/activesupport-3.0.5/lib/active_support/notifications.rb:54:in `instrument'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/template.rb:127:in `render'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/render/layouts.rb:80:in `_render_layout'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/render/rendering.rb:62:in `_render_template'
/var/lib/gems/1.8/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `instrument'
/var/lib/gems/1.8/gems/activesupport-3.0.5/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/var/lib/gems/1.8/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `instrument'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/render/rendering.rb:56:in `_render_template'
/var/lib/gems/1.8/gems/actionpack-3.0.5/lib/action_view/render/rendering.rb:26:in `render'
/data/sites/fundraisers-stage/releases/20110316194843/config/initializers/error_pages.rb:15:in `rescue_action_in_public'
In rails 3.2, it's easier than that:
Add this to config/application.rb:
config.exceptions_app = self.routes
That causes errors to be routed via the router. Then you just add to config/routes.rb:
match "/404", :to => "errors#not_found"
I got this info from item #3 on the blog post "My five favorite hidden features in Rails 3.2" by By José Valim.
I would suggest using rescue_from instead. You would just rescue from specific errors rather than overriding rescue_action_in_public. This is especially useful when dealing with user-defined errors or controller-specific errors.
# ApplicationController
rescue_from ActionController::RoutingError, :with => :render_404
rescue_from ActionController::UnknownAction, :with => :render_404
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
rescue_from MyApp::CustomError, :with => :custom_error_resolution
def render_404
if /(jpe?g|png|gif)/i === request.path
render :text => "404 Not Found", :status => 404
else
render :template => "shared/404", :layout => 'application', :status => 404
end
end
# UsersController
rescue_from MyApp::SomeReallySpecificUserError, :with => :user_controller_resolution
http://api.rubyonrails.org/classes/ActiveSupport/Rescuable/ClassMethods.html
The exception notifier has a method called notify_about_exception to initiate the error notification on demand.
class ApplicationController < ActionController::Base
include ExceptionNotification::Notifiable
rescue_from Exception, :with => :render_all_errors
def render_all_errors(e)
log_error(e) # log the error
notify_about_exception(e) # send the error notification
# now handle the page
if e.is_a?(ActionController::RoutingError)
render_404(e)
else
render_other_error(e)
end
end
def render_404_error(e)
# your code
end
def render_other_error(e)
# your code
end
end
I have also faced such problem. The problem is because of attachment_fu gem or plugin. Just uninstall it and use any other plugin or gem will solve your problem.
I have been debugging this the entire day.
I have two models in my application: teaClass & tea. In teaclass.rb, I have
has_many :teas
In tea.rb, I have 'belongs_to :teaclass`.
I try to make the url looks like this "..teaclasses/:id/teas/:id"; so in teas_controller.rb, I put before_filter :get_teaClass
def show
#tea = #teaclass.teas.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => #tea }
end
end
def new
if #teaclass.teas
#tea = #teaclass.teas.new
#teaclass.teas << #tea
##tea = Tea.new
else
flash[:notice=>"failed"]
#tea = Tea.new
#teaclass.teas << #tea
end
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => #tea }
end
end
def get_teaClass
begin
#teaclass = Teaclass.find(params[:teaclass_id])rescue
redirect_to teaclass_path, :notice => "Teaclass Required!"
end
end
But I keep getting an error saying "unknown attribute: teaclass_id"
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2906:inassign_attributes'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2902:in `each'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2902:in `assign_attributes'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2474:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:380:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:380:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:380:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2178:in `with_scope'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_proxy.rb:207:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_proxy.rb:207:in `with_scope'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/association_collection.rb:376:in `method_missing'
/home/jianpchen/repo/Teashop/app/controllers/teas_controller.rb:31:in `new'
Can anyone help me on this? Thank you.
I try to make the url looks like this "..teaclasses/:id/teas/:id"; so in teas_controller.rb, I put before_filter :get_teaClass
This only matters if you are trying to get nested routes setup but id doesn't sound like you are doing that.
What you need to do is actually add the foreign id to the database. So check schema.rb and make sure that column exists.
Here is what you need to do.
Make sure you actually have the foreign in the database table tea.
If you do skip to the next step where I will show you a better way to write your code.
If you do not have 'tea_class_id' as an integer value on your 'tea' table you need to add it.
script/generate migration add_tea_class_id_to_tea
rake db:migrate
Now This is how your code should be written
routes.rb
map.resources :teas
map.resources :teas_classes
Models
models/tea.rb
class Tea < ActiveRecord::Base
belongs_to :tea_class
end
tea_class.rb
class TeaClass < ActiveRecord::Base
has_many :teas
end
controllers
teas_controller.rb
def new
#tea = Tea.new
end
def show
#tea = tea.find(params[:id)
end
def create
#tea = Tea.new(params[:tea])
if #tea.save
redirect_to teas_path
else
render :action => 'new'
end
end
views
This is really important. Make sure you are passing the :tea_class_id as a parameter when you create a tea otherwise it doesn't know how to make the association. It's kinda behind the stage because you send params[:tea] but it is in those parameters where the tea_class_id is actually sent.
So... in your view you need to have some sort of way for users to choose a category or as you have it tea class and that is usually done with a select box when it is a one to many association.
new.html.erb
<% form_for(#tea) do |t| %>
<%= t.collection_select :tea_class_id TeaClass.all, :id, :name %>
<% end %>
Make sure you have tea classes to actually fill the collection_select method. Google that plus rails api if you don't get what's going on.
Nested Routes (on the side)
Looked like you were trying to get the routes like teaclasses/:id/teas/:id. This is called nested routing and you will want to set that up in your routes.rb
map.resources :tea_classes_ do |tea_classes|
tea_classes :teas
end
map.resources :teas
Then you can link to teas_classes/pour/teas/chinese. You should know this command rake routes. It will help you understand how the paths work.
But if you just want the link to get going it should be like this:
<%= link_to "Teas", tea_classes_teas_path(#tea_class)%>
You need to supply #teas do the link because it takes the id from that and when you click it gives it to the teas_controller' asparams[:teas_class_id]`. You don't need to do anything without. It will automatically be in the url.
If you look at your logs, you'll see what the params has contains. Given your code and explanation, there is not key teaclass_id in params. You most likely are looking for :id. If you want to access :teaclass_id, you'll probably need to set that up in your route
match 'controller/:teaclass_id' => 'controller#show'