NameError Link I'm try to launch my ruby application using rails server . Prior to that I used $ rails generate controller simple_pages index. The error is generated saying NameError in SimplePages#index on http://localhost:3000/
Tried checking the index.html.erb and application.html.erb files along with routes.rb file under config folder
routes.rb
Rails.application.routes.draw do
root 'simple_pages#index'
get 'index', to: 'simple_pages#index'
end
index.html.erb
<!DOCTYPE html>
<html>
<head>
<title>R2</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<nav>
<ul>
<li><%= link_to "Home",root_path %></li>
<li><%= link_to "About",simple_pages_about_path %></li>
<li><%= link_to "Contact",simple_pages_contact_path %></li>
</ul>
</nav>
<%= yield %>
</<footer>
© 2018 Bike Berlin
</footer>
</body>
</html>
application.html.erb
<p id="notice"><%= notice %></p>
<h1>Simple Pages</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% #simple_pages.each do |simple_page| %>
<tr>
<td><%= link_to 'Show', simple_page %></td>
<td><%= link_to 'Edit', edit_simple_page_path(simple_page) %></td>
<td><%= link_to 'Destroy', simple_page, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Simple Page', new_simple_page_path %>
The page should display no errors.
Stack trace as follows
app/views/simple_pages/index.html.erb:25:in _app_views_simple_pages_index_html_erb___2005229969295768109_70270503512740'
actionview (5.2.2) lib/action_view/template.rb:159:in 'block in render'
activesupport (5.2.2) lib/active_support/notifications.rb:170:in 'instrument'
actionview (5.2.2) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.2) lib/action_view/template.rb:157:in `render'
actionview (5.2.2) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.2) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.2) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.2) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.2) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.2) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.2) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.2) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.2) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.2) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.2) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.2) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.2) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.2) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.2) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.2) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.2) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.2) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.2) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.2) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/saishbhende24/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (5.2.2) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.2) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:45:in `render'
actionpack (5.2.2) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (5.2.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (5.2.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (5.2.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.2) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.2) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.2) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.2) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.2) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.2) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.2) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.2) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.2) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.2) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.2) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.2) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.2) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.2) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.2) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.2) lib/action_dispatch/routing/route_set.rb:840:in `call'
rack (2.0.6) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.6) lib/rack/etag.rb:25:in `call'
rack (2.0.6) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.6) lib/rack/head.rb:12:in `call'
actionpack (5.2.2) lib/action_dispatch/http/content_security_policy.rb:18: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'
actionpack (5.2.2) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.2) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.2) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:61: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:30: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'
actionpack (5.2.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
railties (5.2.2) lib/rails/engine.rb:524: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'
You don't have a corresponding route/helper (from what we can see). You need to do this in your routes.rb
resources :simple_pages
Follow below steps:
rails g controller simple_pages
# in your routes file
root 'simple_page#index'
resources :simple_pages
# in your controllers
class SimplePageController < ApplicationController
def index
end
end
Replace the following in routes.rb get 'simple_pages/index' wrong get 'index', to: 'simple_pages#index' should be like this
Related
Im new to ruby and I am trying to consume an api and display the data that I get from it but I keep on getting this error : undefined method `[]' for nil:NilClass. It's probably a stupid error but again i am new and cant figure it out. Here's my controller:
class RecipeController < ApplicationController
def Recipe
end
def search
recipe = find_recipe(params[:targetCalories])
unless recipe
flash[:alert] = 'Recipe not found'
return render action: :Recipe
end
#recipe = recipe.first
end
private
def request_api(url)
response = Excon.get(
url,
headers: {
'X-RapidAPI-Host' => URI.parse(url).host,
'X-RapidAPI-Key' => ENV.fetch('RAPIDAPI_API_KEY')
}
)
return nil if response.status != 200
JSON.parse(response.body)
end
def find_recipe(name)
request_api(
"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/mealplans/generate/#{URI.encode(targetCalories)}"
)
end
end
And here's my html:
<div class="container">
<div class="row">
<div class="col-lg-12 mt-5">
<% if flash[:alert] %>
<div class="alert alert-warning"><%= flash[:alert] %></div>
<% end %>
<div class="mx-auto mt-5" style="width: 400px">
<%= form_with(url: search_path, method: 'get', local: true) do %>
<div class="form-group">
<%= label_tag :country, 'Type amount of calories '%>
<%= text_field_tag :country, nil, placeholder: 'Eg. 1000', class: 'form-control' %>
</div>
<%= button_tag 'Search', class: 'btn btn-success btn-block' %>
<% end %>
</div>
</div>
</div>
<div class="container">
<div class="row mt-5">
<div class="col-lg-6">
<h4>Recipe info</h4>
<dl>
<dt>Day</dt>
<dd><%= #recipe['day'] %></dd>
<dt>Capital</dt>
<dd><%= #recipe['type'] %></dd>
<dt>Currency</dt>
<dd><%= #recipe['value'].join(', ') %></dd>
</dl>
</div>
</div>
</div>
Edit: this is the full stack trace
app/views/recipe/Recipe.html.erb:26
actionview (6.0.2.1) lib/action_view/base.rb:274:in `_run'
actionview (6.0.2.1) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.2.1) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.2.1) lib/action_view/template.rb:386:in `instrument_render_template'
actionview (6.0.2.1) lib/action_view/template.rb:183:in `render'
actionview (6.0.2.1) lib/action_view/renderer/template_renderer.rb:59:in `block (2 levels) in render_template'
actionview (6.0.2.1) lib/action_view/renderer/abstract_renderer.rb:89:in `block in instrument'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.2.1) lib/action_view/renderer/abstract_renderer.rb:88:in `instrument'
actionview (6.0.2.1) lib/action_view/renderer/template_renderer.rb:58:in `block in render_template'
actionview (6.0.2.1) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
actionview (6.0.2.1) lib/action_view/renderer/template_renderer.rb:57:in `render_template'
actionview (6.0.2.1) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.2.1) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.2.1) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.2.1) lib/action_view/rendering.rb:118:in `block in _render_template'
actionview (6.0.2.1) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.2.1) lib/action_view/rendering.rb:117:in `_render_template'
actionpack (6.0.2.1) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (6.0.2.1) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.2.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.2.1) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.2.1) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.2.1) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.2.1) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (6.0.2.1) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:85:in `cleanup_view_runtime'
activerecord (6.0.2.1) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:43:in `render'
remotipart (1.4.4) lib/remotipart/render_overrides.rb:23:in `render'
actionpack (6.0.2.1) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:196:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.2.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.2.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.2.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (6.0.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:837:in `call'
rack-pjax (1.1.0) lib/rack/pjax.rb:12:in `call'
remotipart (1.4.4) lib/remotipart/middleware.rb:32: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.2) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.2) lib/rack/etag.rb:27:in `call'
rack (2.2.2) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.2) lib/rack/head.rb:12:in `call'
actionpack (6.0.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.2) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.2) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.2.1) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.2.1) 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.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.2) lib/rack/method_override.rb:24:in `call'
rack (2.2.2) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:83: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.2.1) lib/rails/engine.rb:526:in `call'
puma (4.3.1) lib/puma/configuration.rb:228:in `call'
puma (4.3.1) lib/puma/server.rb:681:in `handle_request'
puma (4.3.1) lib/puma/server.rb:472:in `process_client'
puma (4.3.1) lib/puma/server.rb:328:in `block in run'
puma (4.3.1) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
undefined method `[]' for nil:NilClass on
app/views/recipe/Recipe.html.erb:26
Your #recipe instance variable is nil. Make sure you assign a value to it in your controller, in your def Recipe action.
PS: Controller actions should be lowercase, so def recipe.
I am trying to call a method in view template from its respective controller which is acting weirdly based on different conditions.
PLease note I have tried this after getting failure on this
Triply nested model's form in rails showing error
First of all the controller method is defined as ->
helper_method :find_feature
def find_feature(fid)
#project.features.find(fid)
end
And the view file code where this method is called ->
<% #project.features.each do |fet| %>
<%= "#{fet.name} #{fet.id} " %> #It does work!!
<%= render partial: "taskform",locals: { fetr: find_feature(fet.id) } %>
<% end %>
This throws error as Couldn't find Feature without an ID
in the screenshot islt is shown params[:id] is used that is not right sorry for that I have used the method which is written above as find_feature(fid) very sorry I will update the screenshot once I get to my mqchine
**
the error shows Couldn't find a feature without an id when called by find_feature(fet.id)
**
BUt when I explicitly test with an id, manually, like->
<%= render partial: "taskform", locals: { fetr: find_feature(7) } %>
This works !
Full stack trace-
activerecord (5.2.3) lib/active_record/relation/finder_methods.rb:433:in `find_with_ids'
activerecord (5.2.3) lib/active_record/relation/finder_methods.rb:69:in `find'
activerecord (5.2.3) lib/active_record/associations/collection_association.rb:100:in `find'
activerecord (5.2.3) lib/active_record/associations/collection_proxy.rb:140:in `find'
app/controllers/projects_controller.rb:7:in `find_feature'
actionpack (5.2.3) lib/abstract_controller/helpers.rb:67:in `find_feature'
app/views/projects/show.html.erb:66:in `block in _app_views_projects_show_html_erb__3383934460746758134_70317115637280'
activerecord (5.2.3) lib/active_record/relation/delegation.rb:71:in `each'
activerecord (5.2.3) lib/active_record/relation/delegation.rb:71:in `each'
app/views/projects/show.html.erb:56:in `_app_views_projects_show_html_erb__3383934460746758134_70317115637280'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/ayan/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
actionpack (5.2.3) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/builder.rb:64:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61: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:30: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'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
Request
Parameters:
{"id"=>"4"}
Can anyone suggests what is the reason of this behaviour ?
You are calling the find_feature with this code find_feature(fet.id), so you want to pass the id as a parameter.
Define the helper_method this way then:
def find_feature(fid)
#project.features.find(fid)
end
params[:fid] will look for a request parameter with the key fid in the request's params hash, you are passing a specific value to the method when you call it.
EDIT: Anyway, I'm not sure why are you doing that, you already have the feature object on the fet variable inside the loop, just do this:
<%= render partial: "taskform",locals: { fetr: fet } %>
error shows method calling with parmas[:fid], but you defined method as find_feature(fid) for finding feature , so there must be other method which is overriding , try it by giving different name like find_project_features it will work
Rails 5 application with will_paginate has the following log entry:
Usercontent Load (0.7ms) SELECT "usercontents".* FROM "usercontents" WHERE (id IN (171,172,33,34,35,156,173,144,78,81,88,90,93,96,36,37,38,48,87,89,94,39,175,176) AND contenttype_id = 1)
↳ app/controllers/travels_controller.rb:45
and the controller action specifies
#points = Usercontent.where('id IN (?) AND contenttype_id = ?', #all_valid_usercontents, 1).paginate(page: params[:page], per_page: 18)
if I run in the console that line as
#points = Usercontent.where('id IN (?) AND contenttype_id = ?', [171,172,33,34,35,156,173,144,78,81,88,90,93,96,36,37,38,48,87,89,94,39,175,176], 1).paginate(page: 1, per_page: 18)
then
> #points.class
=> Usercontent::ActiveRecord_Relation
Inserting in the controller debugging points:
Rails.logger.info #a_points.class
Rails.logger.info #points.class
returns
Usercontent::ActiveRecord_Relation
Usercontent::ActiveRecord_Relation
View
<div id='yield_pcontent'>
<%= render 'points' %>
</div>
<div id="infinite-scrolling">
<%= will_paginate %>
</div>
partial _points.html.erb
<div id=points class='tableize'>
<%= render partial: 'point', collection: #points %>
</div>
How can will_paginate thus recognize helper <%= will_paginate %> as an array
undefined method `total_pages' for #<Array:0x00007f9a27d47718>
note: adding require 'will_paginate/array' does not change this behaviour
update
activerecord (5.2.3) lib/active_record/relation/delegation.rb:125:in `method_missing'
will_paginate (3.1.7) lib/will_paginate/view_helpers.rb:73:in `will_paginate'
will_paginate (3.1.7) lib/will_paginate/view_helpers/action_view.rb:33:in `will_paginate'
app/views/travels/_region_points.html.erb:5:in `_app_views_travels__region_points_html_erb__2375899185333558082_70150028432340'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/partial_renderer.rb:344:in `block in render_partial'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/partial_renderer.rb:333:in `render_partial'
actionview (5.2.3) lib/action_view/renderer/partial_renderer.rb:312:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:49:in `render_partial'
actionview (5.2.3) lib/action_view/helpers/rendering_helper.rb:36:in `render'
app/views/travels/cc.html.erb:33:in `_app_views_travels_cc_html_erb___2132430413937746159_70149902220280'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/jerdvo/.rbenv/versions/2.6.1/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
wicked_pdf (1.2.2) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (1.2.2) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (1.2.2) lib/wicked_pdf/pdf_helper.rb:30:in `render'
app/controllers/travels_controller.rb:59:in `cc'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840: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.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61: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'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Update 2
based on a suggestion, two behaviours are being observed:
<%= will_paginate %> => undefined method `total_pages' for #<Array:0x00007f9a261e2540>
<%= will_paginate #points %> => undefined method `total_pages' for #<Usercontent::ActiveRecord_Relation:0x00007f9a26d07ab0>
He is waiting for an Object, not an Array. I share my solution, adapt it to your case.
def render_partial_resource(resources)
if resources.present?
if resources.respond_to?(:model_name)
folder = resources.model_name.name.pluralize.downcase
partial = resources.model_name.name.downcase
else
folder = resources.object.name.pluralize.downcase
partial = resources.object.name.downcase
end
resources.map do |resource|
render partial:"#{folder}/#{partial}", locals:{"#{partial}": resource}
end.join(" ").html_safe
end
end
With the Messageable gem in my Ruby on Rails app, I can access the New Conversation page successfully and chose a user to send to, a title for the message, and of course the body of the message itself.
However, when I click the send button and the page reloads, I receive the following error message:
ArgumentError in ConversationsController#show
wrong number of arguments (3 for 1..2)
Extracted source (around line #4):
2
3 # Returns the Gravatar for the given user.
4 def gravatar_for(user, options = { size: 80 })
5 gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
6 size = options[:size]
7 gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=# {size}"
What could be causing this issue? I'm having so many issues with the New Relic tutorial for Messageable I've been following.. I'm not sure if this error perhaps indicates some problem with there being two seperate gravatar methods that were for two different functions & tutorials (users_helper.rb gravatar method is implemented for profile pictures, from the Hartl tutorial; application_helper.rb gravatar method is implemented for the Messageable new relic tutorial). I don't believe there is any collision between the two causing an error as I haven't been able to fix it yet, but it's a possibility(?)
Anyways, any solution to this problem would be greatly appreciated.
=>Rails version: 4.1.2, Ruby version: 2.1.4
app/helpers/users_helper.rb:
module UsersHelper
# Returns the Gravatar for the given user.
def gravatar_for(user, options = { size: 80 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
image_tag(gravatar_url, alt: user.username, class: "gravatar")
end
end
Full Backtrace:
app/helpers/users_helper.rb:4:in `gravatar_for'
app/views/conversations/show.html.erb:16:in `block in _app_views_conversations_show_html_erb__1169498260752427397_69885071298420'
app/views/conversations/show.html.erb:12:in `_app_views_conversations_show_html_erb__1169498260752427397_69885071298420'
activerecord (4.2.0) lib/active_record/relation/delegation.rb:46:in `each'
activerecord (4.2.0) lib/active_record/relation/delegation.rb:46:in `each'
actionview (4.2.0) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.0) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.0) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.0) lib/action_view/template.rb:143:in `render'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.0) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.0) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.0) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.0) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.0) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.0) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.0) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.0) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
rack-timeout (0.2.0) lib/rack/timeout.rb:108:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
/usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
application_helper:
module ApplicationHelper
# Helper method to easily render Gravatars.
def gravatar_for(user, size = 30, title = user.username)
image_tag gravatar_image_url(user.email, size: size), title: title, class: 'img-rounded'
end
end
_participants.html.erb:
<% conversation.participants.each do |participant| %>
<% unless participant == current_user %>
<%= gravatar_for participant %>
<% end %>
<% end %>
messages_helper.rb:
module MessagesHelper
def recipients_options
s = ''
User.all.each do |user|
s << "<option value='#{user.id}' data-img-src='#{gravatar_image_url(user.email, size: 50)}'>#{user.name}</option>"
end
s.html_safe
end
end
app/views/conversations/show.html.erb:
<% provide(:title, 'Conversation') %>
<p>Chatting with
<%= render 'conversations/participants', conversation: #conversation %>
</p>
<div class="panel panel-default">
<div class="panel-heading"><%= #conversation.subject %></div>
<div class="panel-body">
<div class="messages">
<% #conversation.receipts_for(current_user).each do |receipt| %>
<div class="media">
<% message = receipt.message %>
<div class="media-left">
<%= gravatar_for message.sender, 45, message.sender.name %>
</div>
<div class="media-body">
<h6 class="media-heading"><%= message.sender.name %>
says at <%= message.created_at.strftime("%-d %B %Y, %H:%M:%S") %></h6>
<%= message.body %>
</div>
</div>
<% end %>
</div>
</div>
</div>
In your show template there is code:
<%= gravatar_for message.sender, 45, message.sender.name %>
Unfortunately you have defined gravatar_for in two helpers - one in your UsersHelper, and one in your ApplicationHelper.
It looks like the definition from UsersHelper takes precedence over ApplicationHelper's one. Try removing the one from UserHelper, so the proper method is called.
Good luck!
EDIT
You've mentioned you want to be able to customise the gravatar size, and it is possible with your current implementation of UsersHelper#gravatar_for. Change your code in show as follows:
<%= gravatar_for message.sender, { size: 45 } %>
Please note I removed the third argument so it doesn't cause any errors. Additionally I passed a hash with defined size.
This should do the trick!
Hope that helps!
This is an individual post partial that is rendered as part of a feed partial. So its a partial within a partial.
Everything works fine except for the time_ago_in_words line. The error is
ActionView::Template::Error:
undefined method `>' for nil:NilClass
It doesn't make sense because feed_post is not nil. its rendered 3 times before the error shows up. There is a created_at because the same posts are shown in a different view, so I know its in the database. Also, if I remove time_ago_in_words and just have feed_post.created_at it works fine. I'm stumped.
# shared/_feed_post.html.erb
<li>
<%= link_to gravatar(feed_post.user), feed_post.user %>
<span class="user">
<%= link_to feed_post.user.email, feed_post.user %>
</span>
<span class="post_text">
<%= feed_post.text %>
</span>
<span class="timestamp">
<%= time_ago_in_words(feed_post.created_at) %> #### Here is the trouble
</span>
</li>
Here I render the partial with collection #feed_posts
# shared/_feed.html.erb
<% if #feed_posts.any? %>
<ol class="posts">
<%= render partial: 'shared/feed_post', collection: #feed_posts %>
</ol>
<% end %>
And here is the controller action
def home
#feed_posts = current_user.feed
end
Hopefully this is an easy error for someone to help with. I just don't see it. Any help is appreciated. Thanks
EDIT
Here is the full trace
app/views/shared/_feed_post.html.erb:10:in `_app_views_shared__feed_post_html_erb___559710345292053670_70357988998940'
actionpack (4.0.0.rc2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:399:in `block in collection_with_template'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:395:in `map'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:395:in `collection_with_template'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:291:in `render_collection'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:275:in `block in render'
actionpack (4.0.0.rc2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:274:in `render'
actionpack (4.0.0.rc2) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionpack (4.0.0.rc2) lib/action_view/renderer/renderer.rb:21:in `render'
actionpack (4.0.0.rc2) lib/action_view/helpers/rendering_helper.rb:24:in `render'
app/views/shared/_feed.html.erb:3:in `_app_views_shared__feed_html_erb__1326961751106757393_70357968045160'
actionpack (4.0.0.rc2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
actionpack (4.0.0.rc2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/renderer/partial_renderer.rb:278:in `render'
actionpack (4.0.0.rc2) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionpack (4.0.0.rc2) lib/action_view/helpers/rendering_helper.rb:27:in `render'
app/views/pages/home.html.erb:12:in `_app_views_pages_home_html_erb__4035833185189931772_70357967633720'
actionpack (4.0.0.rc2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.0.rc2) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
actionpack (4.0.0.rc2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.0.rc2) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
actionpack (4.0.0.rc2) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
actionpack (4.0.0.rc2) lib/action_view/renderer/template_renderer.rb:47:in `render_template'
actionpack (4.0.0.rc2) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionpack (4.0.0.rc2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionpack (4.0.0.rc2) lib/action_view/renderer/renderer.rb:23:in `render'
actionpack (4.0.0.rc2) lib/abstract_controller/rendering.rb:127:in `_render_template'
actionpack (4.0.0.rc2) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionpack (4.0.0.rc2) lib/abstract_controller/rendering.rb:120:in `render_to_body'
actionpack (4.0.0.rc2) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
actionpack (4.0.0.rc2) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
actionpack (4.0.0.rc2) lib/abstract_controller/rendering.rb:97:in `render'
actionpack (4.0.0.rc2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.0.0.rc2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.0.0.rc2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.0.0.rc2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.0.0.rc2) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.0.0.rc2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.0.0.rc2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.0.0.rc2) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.0.0.rc2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.0.0.rc2) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.0.0.rc2) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.0.rc2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.0.rc2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.0.rc2) lib/active_support/callbacks.rb:403:in `_run__533002015063756194__process_action__callbacks'
activesupport (4.0.0.rc2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0.rc2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.0.rc2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.0.rc2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0.rc2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0.rc2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.0.rc2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.0.rc2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.0.rc2) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.0.rc2) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0.rc2) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0.rc2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0.rc2) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0.rc2) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0.rc2) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0.rc2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0.rc2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/routing/route_set.rb:655:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0.rc2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0.rc2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0.rc2) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0.rc2) lib/active_support/callbacks.rb:373:in `_run__3615549091380738184__call__callbacks'
activesupport (4.0.0.rc2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0.rc2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0.rc2) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0.rc2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0.rc2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0.rc2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0.rc2) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0.rc2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0.rc2) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0.rc2) lib/rails/engine.rb:511:in `call'
railties (4.0.0.rc2) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Try this
<li>
<%= link_to gravatar(feed_post.user), feed_post.user %>
<span class="user">
<%= link_to feed_post.user.email, feed_post.user %>
</span>
<span class="post_text">
<%= feed_post.text %>
</span>
<span class="timestamp">
<%= time_ago_in_words(feed_post.created_at) unless feed_post.created_at.blank?%> #### Here is the trouble
</span>
</li>
I recently had the same problem, then I found out that it was caused by a new_record object on the page. I tried to combine new action and index action on the same page. In your case, I suspect that you have #feed_posts=[parent_object].feed_posts and #feed_post=[parent_object].feed_posts.build in your feed_post controller.