SyntaxError in ArticlesController#create on Ruby on Rails - ruby-on-rails

i'm having some trouble with this code. Actually is pretty simple, but i can't find the problem. The page was working yesterday, but now throws me an
" SyntaxError in ArticlesController#new"
and
"/home/peyu/workspace/blog01/app/controllers/articles_controller.rb:30: syntax error, unexpected keyword_end, expecting end-of-input"
I think i'm missing an "end" or something, but i can't find it. Here's the code
class ArticlesController < ApplicationController
def index
#articles = Article.all
end
def show
#article = Article.find(params[:id])
end
def new
#article = Article.new
end
def create
#article = Article.new(article_params)
if #article.save
redirect_to #article
else
render 'new'
end
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
So... any idea where's my mistake? Thank you in advance!
And this is the console output:
Started GET "/articles/new" for 127.0.0.1 at 2015-05-10 06:34:10 -0300
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
/home/peyu/workspace/blog01/app/controllers/articles_controller.rb:22: warning: else without rescue is useless
SyntaxError (/home/peyu/workspace/blog01/app/controllers/articles_controller.rb:30: syntax error, unexpected keyword_end, expecting end-of-input):
app/controllers/articles_controller.rb:30: syntax error, unexpected keyword_end, expecting end-of-input
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (4.8ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.2ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (10.6ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (31.6ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/_markup.html.erb (0.6ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.4ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/console.js.erb within layouts/javascript (15.3ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/main.js.erb within layouts/javascript (0.4ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.6ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/index.html.erb (34.2ms)
Started GET "/articles/new" for 127.0.0.1 at 2015-05-10 06:34:10 -0300
/home/peyu/workspace/blog01/app/controllers/articles_controller.rb:22: warning: else without rescue is useless
SyntaxError (/home/peyu/workspace/blog01/app/controllers/articles_controller.rb:30: syntax error, unexpected keyword_end, expecting end-of-input):
app/controllers/articles_controller.rb:30: syntax error, unexpected keyword_end, expecting end-of-input
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (4.6ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.2ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.4ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (21.1ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/_markup.html.erb (1.1ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.4ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/console.js.erb within layouts/javascript (15.7ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/main.js.erb within layouts/javascript (0.3ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.4ms)
Rendered /home/peyu/.rvm/gems/ruby-2.2.1/gems/web-console-2.1.2/lib/web_console/templates/index.html.erb (31.9ms)

You can validate your Ruby file like so
ruby -c articles_controller.rb
I tried it and it is ok. Can you copy & paste the exact file content from the articles_controller.rb please? And which Ruby version are you using?

fyi, the private keyword does not require an end, so the correct indenting should be
private
def article_params
params.require(:article).permit(:title, :text)
end
other than that, the code looks ok. Did you check the code for the template? (probably something like new.html.erb)?

Related

Rails action being called multiple times per request

I have a controller action that's being called three times per browser request. Any ideas? config/routes.rb and application_controller.rb are totally straightforward.
Code below,
config/routes.rb
Rails.application.routes.draw do
root 'tiles#index'
+
controllers/tiles_controller.rb
class TilesController < ApplicationController
def index
puts "this line prints three times in the console per request"
end
+
tiles/index.html.erb
<% if notice %>
<p id="notice"><%= notice %></p>
<% end %>
<div id="tiles">
<%= render "tile", tile: { type: "sam", id: "0" } %>
<%= render "tile", tile: { type: "inputs", id: "1" } %>
<%= render collection: #tiles, partial: "tile" %>
<%= render "tile", tile: { type: "social", id: "1000" } %>
</div>
+
This is the console log:
log/development.log
Started GET "/" for 127.0.0.1 at 2017-08-31 16:56:28 -0400
Processing by TilesController#index as HTML
Started GET "/" for 127.0.0.1 at 2017-08-31 16:56:28 -0400
Processing by TilesController#index as HTML
[1m[36mProject Load (0.5ms)[0m [1m[34mSELECT "projects".* FROM "projects" ORDER BY "projects"."launch_date" ASC LIMIT $1[0m [["LIMIT", 10]]
[1m[36mProject Load (9.1ms)[0m [1m[34mSELECT "projects".* FROM "projects" ORDER BY "projects"."launch_date" ASC LIMIT $1[0m [["LIMIT", 10]]
Rendering tiles/index.html.erb within layouts/application
Rendered tiles/_tile_sam.html.erb (0.3ms)
Rendered tiles/_tile.html.erb (8.0ms)
Rendering tiles/index.html.erb within layouts/application
Rendered tiles/_tile_sam.html.erb (0.0ms)
Rendered tiles/_tile.html.erb (0.9ms)
Rendered tiles/_tile_instagram.html.erb (12.6ms)
...
Rendered tiles/_tile_twitter.html.erb (0.5ms)
Rendered collection of tiles/_tile.html.erb [48 times] (125.9ms)
Rendered tiles/_tile_project.html.erb (0.1ms)
Rendered tiles/_tile_social.html.erb (0.6ms)
Rendered tiles/_tile.html.erb (2.7ms)
Rendered tiles/index.html.erb within layouts/application (166.1ms)
Rendered tiles/_tile_twitter.html.erb (0.6ms)
...
Rendered collection of tiles/_tile.html.erb [48 times] (158.5ms)
Rendered tiles/_tile_social.html.erb (0.1ms)
Rendered tiles/_tile.html.erb (1.0ms)
Rendered tiles/index.html.erb within layouts/application (165.3ms)
Completed 200 OK in 1310ms (Views: 217.1ms | ActiveRecord: 9.1ms)
Completed 200 OK in 1325ms (Views: 204.5ms | ActiveRecord: 0.5ms)
Help!
WOW
Finally figured this one out by removing code related to this action/view line by line. Basically, I was generating a few img tags with empty src fields. Apparently this causes many modern browsers to load a website several times, possibly in an attempt to find missing images or assuming the root URL is the image itself?
Found the behavior cited here:
https://forums.asp.net/t/1804472.aspx?Bizzare+safari+thing+two+page+loads+for+each+page+
page loads twice in Google chrome

NoMethodError (undefined method `fetch_value' for nil:NilClass) in RAILS

Table Name in SQL : road_ratings
Route:
get '/roadRatings', to: "road_ratings#index"
Controller: road_ratings_controller.rb
class RoadRatingsController < ApplicationController
def index
#data = RoadRating.all
render json: #data
end
end
Model: road_rating.rb
class RoadRating < ActiveRecord::Base
end
Upon running the above API, I get the error in rails server logs
NoMethodError (undefined method `fetch_value' for nil:NilClass):
And following error on browser
NoMethodError in RoadRatingsController#index
However when I run the query SELECTroad_ratings.* FROMroad_ratingsLIMIT 1 generated in rails logs on SQL, I get the correct result
Rails Logs:
Started GET "/roadRatings" for ::1 at 2016-10-04 23:55:57 -0400
Processing by RoadRatingsController#index as HTML
RoadRating Load (0.4ms) SELECT `road_ratings`.* FROM `road_ratings` LIMIT 1
Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.4ms)
NoMethodError (undefined method `fetch_value' for nil:NilClass):
app/controllers/road_ratings_controller.rb:4:in `index'
Rendered /Library/Ruby/Gems/2.0.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_source.erb (5.6ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.4ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.1ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (23.1ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.8ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.4ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (16.7ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.3ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.7ms)
Rendered /Library/Ruby/Gems/2.0.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (39.4ms)
Rake Routes:
Kartiks-MacBook-Air:Mayor_project kartik$ rake routes
Prefix Verb URI Pattern Controller#Action
GET / home#default
streets GET /streets(.:format) streets#index
GET /street/:id(.:format) streets#show
potholes GET /potholes(.:format) potholes#index
roadRatings GET /roadRatings(.:format) road_ratings#index

Component rendering with React in Rails not working

Decided to learn React+Rails. I want to render a simple component that looks like this:
app.js
var App = React.createClass({
render: function() {
return (
<div>
Hello React first component.
</div>
);
}
});
ReactDOM.render(
<App />,
document.getElementById('content')
);
react_controller.rb
class ReactController < ApplicationController
def index
render component: 'App'
end
end
view/react/index.html.erb
<%= react_component 'App' %>
I believe this is enough to show text on my screen. I'm getting:
routes.rb
Rails.application.routes.draw do
root 'react#index'
end
And I'm using the react-rails gem.
From the server (local) I get (apparently there's a syntax error somewhere):
Started GET "/" for ::1 at 2016-07-15 07:06:30 +0200
Processing by ReactController#index as HTML
Completed 500 Internal Server Error in 439ms (ActiveRecord: 0.0ms)
ExecJS::RuntimeError (/private/var/folders/86/mvj6bh4j2k94f52_s9xflmf00000gn/T/execjs20160715-4782-pustjs:22203
<div>
^
SyntaxError: Unexpected token <
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:511:25)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:159:18)
at node.js:444:3
):
app/controllers/react_controller.rb:3:in `index'
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1#global/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_source.erb (5.1ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1#global/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (5.0ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1#global/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.8ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1#global/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (73.6ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (1.3ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (1.1ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.9ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.4ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (64.8ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.4ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.4ms)
Rendered /Users/siaw/.rvm/gems/ruby-2.3.1/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (144.0ms)
Try renaming app.js to app.jsx. Also, no need to manually mount component and use react_component at the same time.

Rails, "undefined method `variant' for nil:NilClass" on render json

I am trying to do something really simple, render a json with some stuff.
I do have a view views/api/initialize.html.erb if this counts as useful info.
I have no idea what causes this but the variables filled alright, I checked
My controller:
class ApiController < ApplicationController
def initialize
#articles = Article.all
#areas = Area.all
#languages = Language.all
data_json = { articles: #articles, areas: #areas, languages: #languages }
render json: data_json
end
def index
end
end
My route:
get '/init', controller: 'api', action: 'initialize'
Here is my full error trace from development.log:
NoMethodError (undefined method `variant' for nil:NilClass):
app/controllers/api_controller.rb:9:in `initialize'
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (3.9ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.0ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (14.1ms)
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (44.1ms)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::HTML` to `Mime[:html]`. (called from const_missing at /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/http/mime_type.rb:52)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.4ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.4ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.3ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.4ms)
DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::WEB_CONSOLE_V2` to `Mime[:web_console_v2]`. (called from const_missing at /usr/local/lib/ruby/gems/2.3.0/gems/actionpack-5.0.0.rc1/lib/action_dispatch/http/mime_type.rb:52)
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (36.5ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.4ms)
Rendering /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.4ms)
Rendered /usr/local/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (59.3ms)
Can you locate where the problem is here?
Thank you.
Initailize probably reserved already by Ruby. Just change something not reserved names like test_api_initialize or better api_init.
def api_inits
end
routes:
get '/init' => 'api#api_inits', as: :init

ActiveRecord::RecordNotDestroyed

I can't understand why the destroy method doesn't work only in just one class.
That's the code:
# DELETE /routes/1
# DELETE /routes/1.json
def destroy
#route.destroy
respond_to do |format|
format.html { redirect_to routes_url, notice: 'Route was successfully destroyed.' }
format.json { head :no_content }
end
end
I also tried this:
def destroy
#route = Route.find(params[:id])
if #route.destroy
#route.destroy
end
redirect_to routes_url
end
but with the same result.
Can you help me? thanks
EDIT.
this is the full error.
Started DELETE "/routes/10" for 127.0.0.1 at 2015-09-22 18:24:24 +0200
Processing by RoutesController#destroy as HTML
Parameters: {"authenticity_token"=>"XP84FdlatYqkyB31qi872vNSo2aQjmkjKFlvjCnmsbr5M7nL11eo/QF+mlantF+CgLvag6leu4k4dGj8SMSOog==", "id"=>"10"}
Route Load (0.3ms) SELECT "routes".* FROM "routes" WHERE "routes"."id" = ? LIMIT 1 [["id", 10]]
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
(0.1ms) begin transaction
Reservation Load (0.2ms) SELECT "reservations".* FROM "reservations" WHERE "reservations"."route_id" = ? [["route_id", 10]]
(0.2ms) rollback transaction
Completed 500 Internal Server Error in 63ms (ActiveRecord: 3.4ms)
ActiveRecord::RecordNotDestroyed (ActiveRecord::RecordNotDestroyed):
app/controllers/routes_controller.rb:60:in `destroy'
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (12.3ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (6.0ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.8ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (49.7ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (0.6ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.6ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.6ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.7ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (33.4ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (0.5ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.8ms)
Rendered /home/railsuser/.rvm/gems/ruby-2.2.2/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (67.0ms)
I can only think of there being a dependency issue based on this:
Reservation Load (0.2ms) SELECT "reservations".* FROM "reservations" WHERE "reservations"."route_id" = ? [["route_id", 10]]
Do you have any validations or restrictions on that relationship?
Also, this portion:
if #route.destroy
#route.destroy
end
redirect_to routes_url
probably should be changed to something like below if you mean to redirect based on success:
if #route.destroy
redirect_to some_other_path
else
redirect_to routes_url
end

Resources