2

I'm having some issues with routing in Rails.

I already have a model in place for a Project model, so I generated some default controllers and views using rails generate scaffold_controller, e.g. rails generate scaffold_controller Project. As expected, I now have a default controller and the associated views.

My routes.rb file contains:

resources :projects

When I try to load /projects/1 in the browser, I get a MissingTemplate error. Here's the dump from the rails server terminal:

Started GET "/projects/1/" for 127.0.0.1 at 2011-11-14 19:39:47 -0800
  Project Load (0.3ms)  SELECT `projects`.* FROM `projects` WHERE `projects`.`id` = 1 LIMIT 1

ActionView::MissingTemplate (Missing template projects/show, application/show with {:handlers=>[:erb, :builder], :formats=>[:html], :locale=>[:en, :en]}. Searched in:
):
  app/controllers/projects_controller.rb:18:in `show'

These are scaffolded controllers/views, so there are already files in place for /app/views/projects/show.html.erb, etc. What am I doing wrong? I'm a bit of a rails noob so any tips are appreciated :)

Edit: contents of projects#show

  # GET /projects/1
  # GET /projects/1.json
  def show
    @project = Project.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @project }
    end
  end
R B
  • 31
  • 1
  • 8
  • show your "show" action in app/controllers/projects_controller.rb – Igor Kapkov Nov 15 '11 at 04:19
  • try `rake routes` and find your route, `/projects` works normally? – Igor Kapkov Nov 15 '11 at 04:40
  • The "Searched in:" part of the error message should, by default, point to your views folder, and not as in your case, be empty. I'm afraid i don't really know what can cause this. – cvshepherd Nov 15 '11 at 08:24
  • @RB did you find a solution for this? I am facing the same problem. I will appreciate if you can share the solution. – Tabrez Dec 19 '11 at 16:07
  • @Tabrez see the answer to this question for how I fixed it! It's a pretty simple fix. – R B Dec 19 '11 at 21:35

1 Answers1

0

The issue is connected with RJS in Rails 3.1. Removing this line:

config.action_view.debug_rjs = true

from environments/development.rb fixed it.

The issue arose for me because I had previously been developing in Rails 3.0, then upgraded my Rails installation to version 3.1.

R B
  • 31
  • 1
  • 8