Jazz
Jazz

Reputation: 1090

Ruby on Rails: After change in view, website not updating

I don't think I quite understand how rails updates its view pages. I have deleted a piece of code in my index view, and when I go to refresh page, the code is still present. I tried restarting the server, and I can't think what else to do. Must be a simple thing that I haven't learnt yet, as I'm new to rails. Thanks

EDIT:

Routes

    projects GET    /projects(.:format)          projects#index
             POST   /projects(.:format)          projects#create
 new_project GET    /projects/new(.:format)      projects#new
edit_project GET    /projects/:id/edit(.:format) projects#edit
     project GET    /projects/:id(.:format)      projects#show
             PUT    /projects/:id(.:format)      projects#update
             DELETE /projects/:id(.:format)      projects#destroy
      search        /search(.:format)            projects#search
        root        /                            projects#index

config/routes.rb:

FinalApp::Application.routes.draw do
    resources :projects
    match "search" => "projects#search", :as => :search
    root :to => 'projects#index'
end

Index action in Project Controller:

def index
    @projects = Project.all



respond_to do |format|
      format.html # index.html.erb
      format.json { render :json => @projects }
    end
  end

Upvotes: 3

Views: 10331

Answers (4)

Mark Hewitt
Mark Hewitt

Reputation: 197

I was doing a tutorial and had run rails server in the directory outside of app. I'm pretty sure I stopped and started the server a couple of times, navigated around directories, then I made some changes and they weren't showing. I stopped the server, changed into app then started the server again, I got what I expected. If you're having trouble, it might be worth checking that.

Upvotes: 0

Hugo Logmans
Hugo Logmans

Reputation: 2252

If it stays the same after editing the html, you are not viewing what you think you are viewing.

  • Maybe you have both a index.html.erb and a index.html.haml file?
  • Are you sure you did not accidently copy the index.html.erb outside the app/views/projects/ folder, so Rails takes the one in that location?

Upvotes: 4

Resure
Resure

Reputation: 436

Make sure that your config/routes.rb points #index to the right controller and action.

Upvotes: 3

Shreyas Agarwal
Shreyas Agarwal

Reputation: 1128

Try deleting the index.html file present in the public folder of your app.

Upvotes: 3

Related Questions