I'm learning Rails (so this is probably a stupid error). I'm trying to write an edit screen that updates a parent and its children at the same time. When I hit save I get:
NoMethodError in TasksController#update
undefined method `to_sym' for #<Arel::Attributes::Integer:0x00000004d11970>
I can't figure out what has caused this and where/what this integer object is. Can anyone give me any pointers?
EDIT: I can make this work if I start from scratch with a new Rails project. The parameters that are raising the error are the ones under the key "flactions_attributes". There seem to be some values missing from that, but that's not the problem.
Detail
The parent model is Task, the child is Flaction. (Take it from me, you don't want to name a table 'action' in Rails...)
The Error page also helpfully shows the params hash (please pardon my 'comedy' test data.):
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"QS1gVSz+LKNIyBsIdnSMVfciBA+3j0nFK37477A7mps=",
"task"=>{"name"=>"Finish secret lair",
"description"=>"",
"flactions_attributes"=>{"0"=>{"name"=>"Choose a colour scheme",
"notes"=>"Ask The Voices?",
"id"=>"80"},
"1"=>{"name"=>"Pick a name",
"notes"=>"Something with skulls in it?",
"id"=>"81"}}},
"x"=>"3",
"y"=>"14",
"id"=>"53"}
Here's the update method in the controller. AFAICS it's completely vanilla:
def update
#task = Task.find(params[:id])
respond_to do |format|
if #task.update_attributes(params[:task])
format.html { redirect_to(#task, :notice => 'Task was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => #task.errors, :status => :unprocessable_entity }
end
end
end
So: #task.update_attributes finds an integer and tries to run to_sym on it. The only thing I pass to update_attributes is params, and there are no integer keys there. How do I work out what is going on?
Here's the _form file, FWIW:
<%= form_for(#task) do |f| %>
<% if #task.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#task.errors.count, "error") %> prohibited this task from being saved:</h2>
<ul>
<% #task.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="<%= #task.hold ? 'task held' : 'task' %>" >
<div class="field name">
<%= f.text_field :name, size: 20 %>
<span class="buttons">
<%= if #task.hold
link_to image_tag('unhold-icon.png', alt: 'Un-hold'), change_hold_task_path(#task)
else
link_to image_tag('hold-icon.png', alt: 'Hold'), change_hold_task_path(#task)
end %>
<%= link_to image_tag('delete-icon.png', alt: 'Delete'), #task, confirm: 'Are you sure?', method: :delete %>
</span>
</div>
<div class="field desc">
<%= f.text_area :description, rows: 3, cols: 95 %>
</div>
<table>
<% f.fields_for :flactions do |a| %>
<tr>
<td class="field"> <%= a.text_field :name %> </td>
<td class="field"> <%= a.text_area :notes, rows: 2, columns: 40 %> </td>
<td class="buttons">
<%= link_to image_tag("up-icon-small.png", alt: 'Move Up'), move_flaction_path(a.object, direction: "up") %>
<%= link_to image_tag("down-icon-small.png", alt: 'Move Down'), move_flaction_path(a.object, direction: "down") %>
<%= link_to image_tag("delete-icon-small.png", alt: 'Delete'), a.object, :confirm => 'Are you sure?', :method => :delete %>
</td>
</tr>
<% end # f.fields_for %>
</table>
<%= image_submit_tag('save-icon.png', alt: 'Save') %>
</div> <!-- of div.task or div.task_held -->
<% end %>
EDIT: Stack trace, as requested:
activerecord (3.0.8) lib/active_record/base.rb:1267:in `block in expand_hash_conditions_for_aggregates'
activerecord (3.0.8) lib/active_record/base.rb:1266:in `each'
activerecord (3.0.8) lib/active_record/base.rb:1266:in `expand_hash_conditions_for_aggregates'
activerecord (3.0.8) lib/active_record/relation/query_methods.rb:225:in `build_where'
activerecord (3.0.8) lib/active_record/relation/query_methods.rb:76:in `where'
activerecord (3.0.8) lib/active_record/relation/spawn_methods.rb:124:in `apply_finder_options'
activerecord (3.0.8) lib/active_record/relation/finder_methods.rb:143:in `all'
activerecord (3.0.8) lib/active_record/nested_attributes.rb:364:in `assign_nested_attributes_for_collection_association'
activerecord (3.0.8) lib/active_record/nested_attributes.rb:254:in `flactions_attributes='
activerecord (3.0.8) lib/active_record/base.rb:1564:in `block in attributes='
activerecord (3.0.8) lib/active_record/base.rb:1560:in `each'
activerecord (3.0.8) lib/active_record/base.rb:1560:in `attributes='
activerecord (3.0.8) lib/active_record/persistence.rb:131:in `block in update_attributes'
activerecord (3.0.8) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.8) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.8) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.8) lib/active_record/persistence.rb:130:in `update_attributes'
app/controllers/tasks_controller.rb:62:in `block in update'
actionpack (3.0.8) lib/action_controller/metal/mime_responds.rb:264:in `call'
actionpack (3.0.8) lib/action_controller/metal/mime_responds.rb:264:in `retrieve_response_from_mimes'
actionpack (3.0.8) lib/action_controller/metal/mime_responds.rb:191:in `respond_to'
app/controllers/tasks_controller.rb:61:in `update'
actionpack (3.0.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.8) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.8) lib/active_support/callbacks.rb:436:in `_run__950750868564864989__process_action__1833593346352443574__callbacks'
activesupport (3.0.8) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.8) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.8) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.8) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.8) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.8) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.8) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.8) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.8) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:493:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.8) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.8) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.8) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.8) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.8) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.8) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.8) lib/rails/application.rb:168:in `call'
railties (3.0.8) lib/rails/application.rb:77:in `method_missing'
railties (3.0.8) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.3) lib/rack/content_length.rb:13:in `call'
rack (1.2.3) lib/rack/handler/webrick.rb:52:in `service'
/usr/lib/ruby/1.9.2-p180/webrick/httpserver.rb:111:in `service'
/usr/lib/ruby/1.9.2-p180/webrick/httpserver.rb:70:in `run'
/usr/lib/ruby/1.9.2-p180/webrick/server.rb:183:in `block in start_thread'
GOT IT! This wins my personal running prize for the least helpful Rails error ... so far.
The problem was caused because I'd written my own Task.flactions method in the model. Once I deleted that, it worked fine. So, one more thing to remember never to do again: don't override methods that Rails creates for you.
Incidentally, as far as I can tell, the ONLY place parent-child forms in Rails 3 are currently documented is in ri form_for. There are examples there, too. Worth looking at.
Related
I've set up the impressionist gem in my Film model. It has been working fine, updating the impressions count, but suddenly I've been receiving the following error when trying to GET the Films#Show page.
undefined method `cookie_value' for "60cb104e4befe185a8b81aac9a2c5e3c":String
It seems like it has something to do with the session_hash, but not sure how to solve this issue.
Does anyone have any ideas?
Here is my Film model:
class Film < ApplicationRecord
acts_as_votable
is_impressionable
mount_uploader :cover, ImageUploader
mount_uploader :video, VideoUploader
mount_uploader :trailer, VideoUploader
def score
self.get_upvotes.size - self.get_downvotes.size
end
extend FriendlyId
friendly_id :title, use: :slugged
# one film has many reviews
has_many :reviews, dependent: :destroy
validates :title, presence: true
validates :author, presence: true
validates :cover, presence: true
validates :description, presence: true
end
Films show page
<%= render "shared/ticker" %>
<div class="back-to-films">
<%= link_to films_path do %>
<span><%= image_tag "BackArrow1.svg" %> </span><h3 class="back-to-gallery">Back to film gallery</h3>
<% end %>
</div>
<section class="film-show-grid">
<div class="film-show-img" onclick="toggle();">
<%= image_tag #film.cover.show.url %>
</div>
<div class="film-show-info">
<span><% if #film.is_top_pick %>
<%= image_tag "is_featured.svg", :class => "top-pick-show" %>
<% end %></span>
<span class="liking-target">
<%= link_to like_film_path(#film), class: "upvoted {liked_or_not}", method: :put, remote: :true do %>
<%= image_tag "Polygon2.svg", :class => "polygon" %>
<% end %>
<span class="like_count">
<%= #film.get_likes.size %>
</span>
</span>
<span class="views">
<%= image_tag "view.svg", :class => "eyeball" %>
<span class="impressions"><%= #film.impressionist_count(:filter=>:ip_address) %></span>
</span>
<div class="">
<h2 class="film-title"><%= #film.title %></h2>
<h6 class="film-author"><%= #film.author %></h6> <span><%= #film.description %></span>
<p class="film-description"><%= #film.description_body %></p>
</div>
<div class="play-button" onclick="toggle();">
<span> Play </span> <%= image_tag "play.svg", :class => "play-symbol" %>
</div>
<div class="preview-button" onclick="toggleTrailer();">
Trailer
</div>
<%= link_to film_reviews_path(#film) do %>
<div class="cafe-talk-button">
Café talk
</div>
<% end %>
And my full stack trace
impressionist (2.0.0) app/controllers/impressionist_controller.rb:143:in `session_hash'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:60:in `associative_create_statement'
impressionist (2.0.0) app/controllers/impressionist_controller.rb:27:in `impressionist'
app/controllers/films_controller.rb:28:in `show'
actionpack (6.0.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.2) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.2) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.3.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.2) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.2) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.2) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.2) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.3.2) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.3.2) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.0.3.2) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.0.3.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.0.3.2) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.3.2) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.2) lib/action_dispatch/routing/route_set.rb:834:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.2) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.3.2) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.2) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.4) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.4) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.4) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.4) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.2) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.3.2) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.3.2) lib/rails/engine.rb:527:in `call'
puma (4.3.5) lib/puma/configuration.rb:228:in `call'
puma (4.3.5) lib/puma/server.rb:713:in `handle_request'
puma (4.3.5) lib/puma/server.rb:472:in `process_client'
puma (4.3.5) lib/puma/server.rb:328:in `block in run'
puma (4.3.5) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
I updated a legacy Rails application that is using the impression gem to version 6 and ran into the same exception. I worked around it by specifying a specific commit for the impression gem in the Gemfile:
gem 'impressionist',
git: 'git#github.com:charlotte-ruby/impressionist.git',
ref: '46a582ff8cd3496da64f174b30b91f9d97e86643'
The reason for this is that the fix for the exception is not in their latest release (2.0.0) but is in its master branch.
I have a form:
<%= form_tag generate_report_path(:header => true) do |f| % >
<div class="container-fluid">
<div style="padding-right:10px">
<%= select_tag(:report_id, options_for_select(
[["Select Report Type", 0],
["Report1", 1],
["Report2", 2],
["Report3", 3]]), id: "report_selection") %>
<%= hidden_field_tag :format, :pdf %>
I have a submit button and a checkbox right next to it:
<%= button_tag "Generate Report", class: 'btn btn-sm btn-primary'%>
<%= label_tag do %>
<%= check_box_tag "format_reqd", "format_reqd", false %>
Check for Numeric format
<% end %>
When the user selects the checkbox and clicks on the Generate Report button, I would like to display an alert to the user "your report would be emailed to you in a few minutes"; but the page should not be refreshed.
How can I achieve these two:
Disable page refresh?
Display a flash message?
Please help!
UPDATE:
I added this to my controller (called report_controller):
def reportgen
respond_to do |format|
format.js { flash.now[:alert] = "Report generation has been initiated. You will receive an email in approximately 4 - 5 minutes with a link to download the report."}
end
end
\app\views\report\reportgen.js.erb
$("#flash").html('<%= j render partial: "shared/notice_banner" %>');
application.html.erb
<div id="flash">
<% if alert.present? %>
<%= render partial: "shared/notice_banner" %>
<% end %>
</div>
<% flash.each do |key, value| %>
<% if key.to_s == "alert" %>
<div style= "color: #FF0000" class="text-center <%= flash_class(key) %>">
<%= value %>
</div>
<% else %>
<div class="lead text-center <%= flash_class(key) %>">
<%= value %>
</div>
<% end %>
<% end %>
<%= yield %>
app\views\shared\_notice_banner.html.erb
<div data-alert class="alert-box">
<%= alert %>
×
</div>
And this is my code to add the button and checkbox in my form:
<div id="generate_button" style="display: none; float:left;">
<%= button_tag "Generate Report", class: 'btn btn-sm btn-primary'%>
</div>
<div id="report_type_drop" style="display: none;padding-top:5px;padding-left:5px">
<%= label_tag do %>
<%= check_box_tag "format_reqd", "format_reqd", false %>
Check for Numeric format
<% end %>
</div>
With the above code these are the results for my 2 issues in my original question right now:
Disable page refresh - this works perfectly fine now
Display flash message - this does not work!
UPDATE:
I also see this error now (not sure what's causing this though):
ActionController::UnknownFormat (ReportController#reportgen is missing a template for this request format and variant.
request.formats: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]
request.variant: []):
actionpack (5.0.7.1) lib/action_controller/metal/implicit_render.rb:43:in `default_render'
actionpack (5.0.7.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.0.7.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.0.7.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.0.7.1) lib/abstract_controller/base.rb:188:in `process_action'
actionpack (5.0.7.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.0.7.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:286:in `block (2 levels) in halting'
audited (4.8.0) lib/audited/sweeper.rb:14:in `around'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:405:in `public_send'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:405:in `block in make_lambda'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:285:in `block in halting'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:447:in `block in around'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:286:in `block (2 levels) in halting'
audited (4.8.0) lib/audited/sweeper.rb:14:in `around'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:405:in `public_send'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:405:in `block in make_lambda'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:285:in `block in halting'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:447:in `block in around'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.7.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.7.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.0.7.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.0.7.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.7.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.7.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.7.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.0.7.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.7.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.7.1) lib/abstract_controller/base.rb:126:in `process'
actionview (5.0.7.1) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.7.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.7.1) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.7.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.7.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.7.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.7.1) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.7.1) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.7.1) lib/action_dispatch/routing/route_set.rb:727:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
omniauth (1.4.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.4.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/etag.rb:25:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/conditional_get.rb:38:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/head.rb:12:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.6) lib/rack/session/abstract/id.rb:226:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
activerecord (5.0.7.1) lib/active_record/migration.rb:553:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.7.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.7.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
railties (5.0.7.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.7.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.7.1) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.0.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.7.1) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.0.7.1) lib/rails/rack/logger.rb:24:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
activesupport (5.0.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
actionpack (5.0.7.1) lib/action_dispatch/middleware/static.rb:136:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
railties (5.0.7.1) lib/rails/engine.rb:522:in `call'
newrelic_rpm (6.3.0.355) lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
UPDATE: (update 3)
If I change my controller code to this:
the above stacktrace error goes away
page refresh does not happen - this is good
but the flash message still does not appear
respond_to do |format|
format.json { flash.now[:alert] = "Report generation has been initiated. You will receive an email in approximately 4 - 5 minutes with a link to download the report."}
end
You should use remote: true in your form.
<%= form_tag generate_report_path(:header => true), remote: true do |f| % >
<div class="container-fluid">
<div style="padding-right:10px">
<%= select_tag(:report_id, options_for_select(
[["Select Report Type", 0],
["Report1", 1],
["Report2", 2],
["Report3", 3]]), id: "report_selection")
%>
<%= hidden_field_tag :format, :pdf %>
<%= button_tag "Generate Report", class: 'btn btn-sm btn-primary'%>
<%= label_tag do %>
<%= check_box_tag "format_reqd", "format_reqd", false %>
Check for Numeric format
<% end %>
<% end %>
Above remote: true is responsible for sending ajax request to your
controller method. Here is a complete guide for form_for and remote
requests.
In your method of the controller:
def generate_report
... #Whatever you want to add here.
render js: "alert('Your report would be emailed to you in a few minutes')"
end
Update with the flash message:
Your controller method will now look like:
def generate_report
... #Whatever you want to add here.
respond_to do |format|
format.js { flash[:notice] = "Your report would be emailed to you in a few minutes" }
end
end
Rendered view:
# app/views/users/generate_report.js.erb
$("#flash").html('<%= j render partial: "shared/notice_banner" %>');
# app/views/layouts/application.html.erb
<div id="flash">
<% if notice.present? %>
<%= render partial: "shared/notice_banner" %>
<% end %>
</div>
# app/views/shared/_notice_banner.html.erb
<div data-alert class="alert-box">
<%= notice %>
×
</div>
Here is the detailed answer present.
Hope this will help.
I'm trying to update a selectbox that depends on another selectbox. Depending on the first one, it will search all those records that are related. Should work, this I am doing at the device login but I am getting the following error:
ActionController::RoutingError (uninitialized constant Usuarios::SessionsControllerController):
activesupport (4.2.6) lib/active_support/inflector/methods.rb:263:in `const_get'
activesupport (4.2.6) lib/active_support/inflector/methods.rb:263:in `block in constantize'
activesupport (4.2.6) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.6) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.6) lib/active_support/inflector/methods.rb:259:in `constantize'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:70:in `controller_reference'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:60:in `controller'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:39:in `serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.6) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.6) lib/action_dispatch/routing/route_set.rb:817:in `call'
rack-pjax (1.0.0) lib/rack/pjax.rb:12:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/flash.rb:260:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
remotipart (1.3.1) lib/remotipart/middleware.rb:32:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.6) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.6) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.6) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.6) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.6) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.6) lib/action_dispatch/middleware/static.rb:120:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.6) lib/rails/engine.rb:518:in `call'
railties (4.2.6) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
thin (1.7.0) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.7.0) lib/thin/connection.rb:84:in `catch'
thin (1.7.0) lib/thin/connection.rb:84:in `pre_process'
thin (1.7.0) lib/thin/connection.rb:53:in `process'
thin (1.7.0) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.2.0.1) lib/eventmachine.rb:194:in `run_machine'
eventmachine (1.2.0.1) lib/eventmachine.rb:194:in `run'
thin (1.7.0) lib/thin/backends/base.rb:73:in `start'
thin (1.7.0) lib/thin/server.rb:162:in `start'
rack (1.6.4) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.4) lib/rack/server.rb:286:in `start'
railties (4.2.6) lib/rails/commands/server.rb:80:in `start'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:75:in `tap'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.6) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.6) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<top (required)>'
spring (2.0.0) lib/spring/client/rails.rb:28:in `load'
spring (2.0.0) lib/spring/client/rails.rb:28:in `call'
spring (2.0.0) lib/spring/client/command.rb:7:in `call'
spring (2.0.0) lib/spring/client.rb:30:in `run'
spring (2.0.0) bin/spring:49:in `<top (required)>'
spring (2.0.0) lib/spring/binstub.rb:31:in `load'
spring (2.0.0) lib/spring/binstub.rb:31:in `<top (required)>'
/home/luis/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/home/luis/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
bin/spring:13:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Rendered /home/luis/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb (1.5ms)
Rendered /home/luis/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb (9.7ms)
this is my new.html.erb (view->devise->sessions)
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: "form-horizontal"}) do |f| %>
<h1>Login Form</h1>
<div class="forml">
<div class="form-group">
<div >
<%= f.text_field :login, autofocus: true, :class => "form-control", :placeholder =>"Username or Email", :required => "" %>
</div>
</div>
<div class="form-group">
<div >
<%= f.password_field :password, autofocus: true, :class => "form-control", :placeholder =>"Password", :required => "" %>
</div>
<%= select_tag :empresa, options_for_select(#empresas.map{|e|[e.Empresa, e.id]}), :'data-remote' => 'true', :'data-url' => url_for(:controller => 'sessions_controller', :action => 'busqueda_sucursales', format: 'js') %>
<div id="sucursales"><%= render 'sucursales' %></div>
</div>
</div>
<div class="form-group">
<% if devise_mapping.rememberable? -%>
<div class="checkbox-inline col-md-5">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
</div>
<div>
<%= f.submit "Log in", :class => "btn btn-default submit col-md-10"%>
<div class="form-group">
<%= render "devise/shared/links" %>
</div>
</div>
<div class="clearfix"></div>
<div class="separator">
</div>
<% end %>
this is my partial _sucursales.html.erb(view->devise->sessions)
<div class="form-group">
<%= label_tag :sucursal, "Selecciona sucursal:" %>
<div class="">
<%= select_tag :sucursal, options_for_select(#sucursales.map{|e|[e.Sucursal, e.IdEmpresa]}), class: "form-control js-example-basic-single" %>
</div>
</div>
this is my busqueda_sucursales.js.erb (view->devise->sessions)
$("#sucursales").html("<%= escape_javascript(render("sucursales"))%>")
this is my sessions_controller.rb (controllers->usuarios)
class Usuarios::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# POST /resource/sign_in
# def create
# super
# end
# DELETE /resource/sign_out
# def destroy
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
def busqueda_sucursales #Actualiza las sucursales concorde a las empresas en el acceso
#sucursales = Empresa.where("empresamadre_id = ?", params[:empresa])
respond_to do |format|
format.js
end
end
def new
#empresas = Empresamadre.all
#sucursales = Empresa.where("empresamadre_id = ?", #empresas.first.id)
super
end
def create
super
end
def update
super
end
private
def sign_up_params
allow = [:email, :usuario, :password, :password_confirmation, :nombre, :idempresa]
params.require(resource_name).permit(allow)
end
end
this is my routes.rb
devise_for :usuarios, controllers: {
registrations: "usuarios/registrations",
sessions: "usuarios/sessions",
passwords: "usuarios/passwords"}
resources :usuarios do
get 'usuarios_check', :on => :collection
get 'usuarios_check2', :on => :collection
end
get 'usuarios/sessions_controller/busqueda_sucursales', as: 'busqueda_sucursales'
Reading the first line of your error, it seemed off to see the word Controller repeated:
ActionController::RoutingError (uninitialized constant Usuarios::SessionsControllerController):
This line:
<%= select_tag :empresa, options_for_select(#empresas.map{|e|[e.Empresa, e.id]}), :'data-remote' => 'true', :'data-url' => url_for(:controller => 'sessions_controller', :action => 'busqueda_sucursales', format: 'js') %>
replace :controller => 'sessions_controller' with :controller => 'sessions'
See the examples here: http://apidock.com/rails/ActionView/RoutingUrlFor/url_for
Ive been doing some research and I can't seem to find what Im doing wrong.
I have installed simple_form and nested_form gems but when I use either link_to_add or remove I get the same error.
Heres the code
/fields.html.erb
<%= render 'shared/error_messages', :object => f.object %>
<%= f.input :nombre_cliente, :label => 'Nombre del cliente:', :as => :string %>
<%= f.input :mail_cliente, :label => 'E-mail del cliente:', :as => :string %>
<%= f.input :empresa_cliente, :label => 'Empresa:', :as => :string %>
<%= f.input :confirmada, :label => 'Ha sido confirmada por el cliente.' %>
<%= f.input :confirmacion_cliente, :label => 'Fecha de confirmacion por el cliente:', :as => :date %>
<b>something here</b>
</br></br>
<%= f.simple_fields_for :producto_de_cotizacion do |productos| %>
<%= productos.input :nombre %>
<%= productos.input :descripcion %>
<%= productos.input :precio%>
<%= productos.link_to_remove("Eliminar producto") %>
<% end %>
<%= f.link_to_add "Agregar producto", :producto_de_cotizacion %>
Some of it is in spanish but I think its understandable
Here is the actual error Im getting:
undefined method `link_to_remove' for < SimpleForm::FormBuilder:0x9ccf37c>
That is the entirety of _fields.html.erb, but its being called by the new.html.erb and the edit.html.erb files which are basically identical, Ill post the edit file:
<h1>Agregar Cotizacion</h1>
<div id='admin_view'>
<%= simple_form_for #cotizacion, :html => {:multipart => true} do |f| %>
<%= render "fields", :f => f %>
<%= f.button :submit, 'Actualizar Cotizacion' %>
<% end%>
</div>
After changing it to simple_nested_form I get a new error:
undefined method `klass' for nil:NilClass
and heres the stack
activesupport (3.0.7) lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/builder_mixin.rb:23:in `block in link_to_add'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:37:in `call'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:37:in `block in after_nested_form_callbacks'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:36:in `map'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:36:in `after_nested_form_callbacks'
/home/peanut/.rvm/gems/ruby-1.9.2-p180/bundler/gems/nested_form-57f32788f195/lib/nested_form/view_helper.rb:13:in `simple_nested_form_for'
app/views/cotizacions/edit.html.erb:3:in `_app_views_cotizacions_edit_html_erb__855809706_86735240_354753338'
actionpack (3.0.7) lib/action_view/template.rb:135:in `block in render'
activesupport (3.0.7) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.7) lib/action_view/template.rb:127:in `render'
actionpack (3.0.7) lib/action_view/render/rendering.rb:59:in `block in _render_template'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_view/render/rendering.rb:56:in `_render_template'
actionpack (3.0.7) lib/action_view/render/rendering.rb:26:in `render'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:115:in `_render_template'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:109:in `render_to_body'
actionpack (3.0.7) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
actionpack (3.0.7) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:102:in `render_to_string'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:93:in `render'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:17:in `render'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.0.7) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
activesupport (3.0.7) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.0.7) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:39:in `render'
meta-tags (1.2.4) lib/meta_tags/controller_helper.rb:28:in `render_with_meta_tags'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:14:in `default_render'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:6:in `send_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.7) lib/active_support/callbacks.rb:451:in `_run__761686272__process_action__750077467__callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.7) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:89:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:493:in `call'
warden (0.10.7) lib/warden/manager.rb:35:in `block in call'
warden (0.10.7) lib/warden/manager.rb:34:in `catch'
warden (0.10.7) lib/warden/manager.rb:34:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.4) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.7) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.7) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.4) lib/rack/sendfile.rb:106:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.7) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.4) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.7) lib/rails/application.rb:168:in `call'
railties (3.0.7) lib/rails/application.rb:77:in `method_missing'
railties (3.0.7) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/peanut/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Use :locals => { :f => f }
EDIT: Changing my answer.
I just realized you are using:
simple_form_for
Change that to
simple_nested_form_for
This allows you to use the nested_form options (link_to_add, link_to_remove, etc).
Cheers!
So I changed the new.html.erb and edit.html.erb to look like this:
<h1>Agregar Cotizacion</h1>
<div id='admin_view'>
<%= simple_nested_form_for #cotizacion, :html => {:multipart => true} do |f| %>
<%= render 'fields', :f => f %>
<%= f.button :submit, 'Agregar Cotizacion' %>
<% end%>
</div>
And I added this to the routes.rb file
resources :cotizacions do
resources :producto_de_cotizacions
end
resources :producto_de_cotizacions
Im not exactly sure how but this fixed the issue. Thanks a lot for your help. Cheers!
I have this error, solved by restarting server and adding this code to model:
accepts_nested_attributes_for :photos, :reject_if => :all_blank, :allow_destroy => true
I'm trying to use paperclip to handle file uploads in my Rails app. I'm currently running Paperclip 2.4.1 on Rails 3.0.9, running a WEBrick server on sqlite3.
The form worked fine before adding the file upload portion, but after following the quickstart instructions in the Paperclips docs (http://rdoc.info/gems/paperclip/2.4.1/file/README.md), upon form submission I get the following error:
undefined method `exitstatus' for nil:NilClass
at app/controllers/shows_controller.rb:62:in `create'
Here's the code for my model:
class Show < ActiveRecord::Base
has_many :pictures
has_attached_file :thumb,
:styles => { :thumb => "150x150>" },
:url => "/images/:id/thumb.:extension"
validates_attachment_presence :thumb
validates_presence_of :title
validates_presence_of :start_date
validates_presence_of :end_date
validates_presence_of :description
validates_presence_of :blurb
validates_presence_of :location
def self.current
where("shows.end_date > ?", Time.new).first
end
def self.thumb
image_tag self.thumb.url(:thumb)
end
end
The create method for my controller:
def create
#show = Show.create(params[:show])
respond_to do |format|
if #show.save
format.html { redirect_to(#show, :notice => 'Show was successfully created.') }
format.xml { render :xml => #show, :status => :created, :location => #show }
else
format.html { render :action => "new" }
format.xml { render :xml => #show.errors, :status => :unprocessable_entity }
end
end
(Line 62 is the #show = Show.create(params[:show] line))
My form:
<%= form_for #show, :html => {:multipart => true} do |f| %>
<% if #show.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(#show.errors.count, "error") %> prohibited this show from being saved:</h2>
<ul>
<% #show.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :start_date %><br />
<%= f.date_select :start_date %>
</div>
<div class="field">
<%= f.label :end_date %><br />
<%= f.date_select :end_date %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_area :description %>
</div>
<div class="field">
<%= f.label :blurb %><br />
<%= f.text_field :blurb %>
</div>
<div class="field">
<%= f.label :location %><br />
<%= f.text_field :location %>
</div>
<div class="field">
<%= f.label :thumb %><br />
<%= f.file_field :thumb %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
And the full stack trace:
activesupport (3.0.9) lib/active_support/whiny_nil.rb:48:in `method_missing'
cocaine (0.2.0) lib/cocaine/command_line.rb:35:in `run'
paperclip (2.4.2) lib/paperclip.rb:102:in `run'
paperclip (2.4.2) lib/paperclip/geometry.rb:20:in `from_file'
paperclip (2.4.2) lib/paperclip/thumbnail.rb:35:in `initialize'
paperclip (2.4.2) lib/paperclip/processor.rb:33:in `new'
paperclip (2.4.2) lib/paperclip/processor.rb:33:in `make'
paperclip (2.4.2) lib/paperclip/attachment.rb:397:in `post_process_styles'
activemodel (3.0.9) lib/active_model/attribute_methods.rb:295:in `inject'
paperclip (2.4.2) lib/paperclip/attachment.rb:396:in `each'
paperclip (2.4.2) lib/paperclip/attachment.rb:396:in `inject'
paperclip (2.4.2) lib/paperclip/attachment.rb:396:in `post_process_styles'
activesupport (3.0.9) lib/active_support/ordered_hash.rb:139:in `each'
activesupport (3.0.9) lib/active_support/ordered_hash.rb:139:in `each'
paperclip (2.4.2) lib/paperclip/attachment.rb:392:in `post_process_styles'
paperclip (2.4.2) lib/paperclip/attachment.rb:386:in `post_process'
activesupport (3.0.9) lib/active_support/callbacks.rb:414:in `_run_thumb_post_process_callbacks'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `send'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `run_callbacks'
paperclip (2.4.2) lib/paperclip/callback_compatibility.rb:54:in `run_paperclip_callbacks'
paperclip (2.4.2) lib/paperclip/attachment.rb:385:in `post_process'
activesupport (3.0.9) lib/active_support/callbacks.rb:414:in `_run_post_process_callbacks'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `send'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `run_callbacks'
paperclip (2.4.2) lib/paperclip/callback_compatibility.rb:54:in `run_paperclip_callbacks'
paperclip (2.4.2) lib/paperclip/attachment.rb:384:in `post_process'
paperclip (2.4.2) lib/paperclip/attachment.rb:142:in `assign'
paperclip (2.4.2) lib/paperclip.rb:335:in `thumb='
activerecord (3.0.9) lib/active_record/base.rb:1564:in `send'
activerecord (3.0.9) lib/active_record/base.rb:1564:in `attributes='
activerecord (3.0.9) lib/active_record/base.rb:1560:in `each'
activerecord (3.0.9) lib/active_record/base.rb:1560:in `attributes='
activerecord (3.0.9) lib/active_record/base.rb:1412:in `initialize'
activerecord (3.0.9) lib/active_record/base.rb:502:in `new'
activerecord (3.0.9) lib/active_record/base.rb:502:in `create'
app/controllers/shows_controller.rb:62:in `create'
actionpack (3.0.9) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.9) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.9) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.9) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.9) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.0.9) lib/active_support/callbacks.rb:441:in `_run__918721632__process_action__524098549__callbacks'
activesupport (3.0.9) lib/active_support/callbacks.rb:410:in `send'
activesupport (3.0.9) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `send'
activesupport (3.0.9) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.9) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.9) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.0.9) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.9) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.9) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.9) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.9) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.9) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.9) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.9) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.9) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.9) lib/action_controller/metal.rb:178:in `action'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.9) lib/action_dispatch/routing/route_set.rb:493:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.9) lib/active_record/query_cache.rb:32:in `call'
activerecord (3.0.9) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.9) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.9) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.9) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.9) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.9) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
actionpack (3.0.9) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.9) lib/rails/application.rb:168:in `call'
railties (3.0.9) lib/rails/application.rb:77:in `send'
railties (3.0.9) lib/rails/application.rb:77:in `method_missing'
railties (3.0.9) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.3) lib/rack/content_length.rb:13:in `call'
rack (1.2.3) lib/rack/handler/webrick.rb:52:in `service'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:162:in `start'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:92:in `each'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/Rails/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.2.3) lib/rack/handler/webrick.rb:13:in `run'
rack (1.2.3) lib/rack/server.rb:217:in `start'
railties (3.0.9) lib/rails/commands/server.rb:65:in `start'
railties (3.0.9) lib/rails/commands.rb:30
railties (3.0.9) lib/rails/commands.rb:27:in `tap'
railties (3.0.9) lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
I wasn't able to find any instance of this error elsewhere relating to paperclip; It looks like its bubbling up from within Rails somewhere; any suggestions?
It seems that the command, that is run with cocaine is not correct. Have you configured paperclip's command path with Paperclip.options[:command_path] = "/usr/local/bin/" and installed ImageMagick in this path?
You can find out where ImageMagick is with which convert. This should yield the path to the convert binary of ImageMagick - in my case /usr/local/bin/convert