I am getting this error saying undefined method update. The show and Edit buttons work well. It's just the update that isn't working. I am using friendly_id and the controller is scaffolded with better routing.
Here is my routes:
Rails.application.routes.draw do
resources :static_pages, except: [:show, :edit]
devise_for :users
mount Bootsy::Engine => '/bootsy', as: 'bootsy'
get 'profile' => "users#profile"
root 'indexes#index'
get ':slug', to: 'static_pages#show'
get ':slug/edit', to: 'static_pages#edit'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Here is the static page controller for the update method:
class StaticPagesController < ApplicationController
before_action :set_static_page, only: [:show, :edit, :update]
before_action :static_page_params, only: [:update, :create]
before_action :destroy_static_page, only: :destroy
before_filter :except => [:show] do
redirect_to :new_user_session unless current_user && current_user.role == 5
end
# GET /static_pages
# GET /static_pages.json
def index
#static_pages = StaticPage.all
end
# GET /static_pages/1
# GET /static_pages/1.json
def show
end
# GET /static_pages/new
def new
#static_page = StaticPage.new
end
# GET /static_pages/1/edit
def edit
end
# POST /static_pages
# POST /static_pages.json
def create
#static_page = StaticPage.new(static_page_params)
respond_to do |format|
if #static_page.save
format.html { redirect_to #static_page, notice: 'Static page was successfully created.' }
format.json { render :show, status: :created, location: #static_page }
else
format.html { render :new }
format.json { render json: #static_page.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /static_pages/1
# PATCH/PUT /static_pages/1.json
def update
respond_to do |format|
if #static_page.update(static_page_params)
format.html { redirect_to #static_page, notice: 'Static page was successfully updated.' }
format.json { render :show, status: :ok, location: #static_page }
else
format.html { render :edit }
format.json { render json: #static_page.errors, status: :unprocessable_entity }
end
end
end
# DELETE /static_pages/1
# DELETE /static_pages/1.json
def destroy
#static_page.destroy
respond_to do |format|
format.html { redirect_to static_pages_url, notice: 'Static page was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_static_page
#static_page = StaticPage.find_by_slug(params[:slug])
end
def destroy_static_page
#static_page = StaticPage.find_by_slug(params[:slug])
end
# Never trust parameters from the scary internet, only allow the white list through.
def static_page_params
params.require(:static_page).permit(:title, :video_id, :content, :tags, :author, :date, :slug)
end
end
Here are the views that have been scaffolded for the edit page:
%h1 Editing static_page
= render 'form'
= link_to 'Show', #static_page
\|
= link_to 'Back', static_pages_path
Edit: It has to do with my routes. I can't get the show button to work on the fourm bellow. I try #static_page.slug but that takes me to /page_name/page_name. When I just do #static_page it takes me to /static_page/page_name. What I need it to do is take me to /page_name.
Edit 2: Here is the form partial:
= simple_form_for(#static_page) do |f|
= f.error_notification
.form-inputs
= f.input :title
= f.input :video_id
.bootsy_text_area
= f.bootsy_area :content, :class => 'form-control', rows: 12
= f.input :tags
= f.input :author
= f.input :date
.form-actions
= f.button :submit
You're calling #static_page.update(static_page_params), but in this case, #static_page is nil.
You've defined #static_page as #static_page = StaticPage.find_by_slug(params[:slug]), but this will return nil if no page with that slug is found.
There are two ways you can handle this:
Use find_by_slug! instead, which will raise an exception if no record is found, or:
Check for the presence of nil yourself, and decide how you want to handle it.
Related
I'm trying to remove the obsolete routes of devise, in my api_only rails setup. However i'm in a fuss about how to define them properly with devise_scope. I have the following routes.rb:
# config/routes.rb
Rails.application.routes.draw do
namespace :api do
namespace :users do
devise_scope :user do
resource :confirmations, only: %i[create show], format: false
end
end
end
end
Which refers to the confirmations_controller that contains custom json renders instead of the typical respond_with:
# app/controllers/api/users/confirmations_controller.rb
module Api
module Users
class ConfirmationsController < Devise::ConfirmationsController
# POST /resource/confirmation
def create
self.resource = resource_class.send_confirmation_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
# respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
render json: { status: 201 }, status: :created
else
# respond_with(resource)
render json: { status: 422, errors: resource.errors.keys },
status: :unprocessable_entity
end
end
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
yield resource if block_given?
if resource.errors.empty?
set_flash_message!(:notice, :confirmed)
# respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
render json: { status: 200 }, status: :ok
else
# respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }
render json: { status: 422, errors: resource.errors.keys },
status: :unprocessable_entity
end
end
end
end
end
As can be seen in the routes.rb I only need the create and show endpoints of confirmations. However the current definition results in the following error when running rspec:
Failure/Error: get api_users_confirmations_path, params: { confirmation_token: 'incorrect_token' }
AbstractController::ActionNotFound:
Could not find devise mapping for path "/api/users/confirmations?confirmation_token=incorrect_token".
This may happen for two reasons:
1) You forgot to wrap your route inside the scope block. For example:
devise_scope :user do
get "/some/route" => "some_devise_controller"
end
2) You are testing a Devise controller bypassing the router.
If so, you can explicitly tell Devise which mapping to use:
#request.env["devise.mapping"] = Devise.mappings[:user]
Which tends mostly to the missing devise mapping, considering that the devise_scope is defined properly. However i'm not sure how to solve this properly without having to include the bindings in every devise controller. Is this doable from the routes?
I have never tried to use resources inside of devise_scope.
This is how I have defined it.
devise_scope :user do
delete 'logout', to: 'devise/sessions#destroy'
end
This is how I have defined in one of my application
devise_for :users, path: 'api/v1/accounts', controllers: {
:registrations => 'api/v1/accounts/registrations',
:sessions => 'api/v1/accounts/sessions',
:passwords => 'api/v1/accounts/passwords'
}
devise_scope :user do
get '/sessions/new' => "sessions#new", :as => :new_sessions
get '/sessions/forgot_password' => "sessions#forgot_password", :as => :forgot_password
post '/validate_referral_code' => 'validates#validate_referral_code', as: :validate_referral_code
post '/validate_employment_code' => 'validates#validate_employment_code', as: :validate_employment_code
post '/get_weather' => 'temperature#weather', as: :weather
get '/fetch' => 'zip_codes#fetch', as: :fetch_zip_code
post '/request_demo' => 'demos#create', as: :create
end
namespace :api do
namespace :v1 do
scope :accounts do
resources :third_party_logins, only: [] do
collection do
get :action_name
end
end
end
end
end
I am having a hard time creating the routes to my pages. I have show which works but edit keeps popping up with an error. The current code is a modification of this railscast along with the friendly ID gem. Thank you if you can help.
Here is the controller:
class StaticPagesController < ApplicationController
before_action :set_static_page, only: [:show, :edit, :update, :destroy]
before_filter :except => [:show] do
redirect_to :new_user_session unless current_user && current_user.role == 5
end
# GET /static_pages
# GET /static_pages.json
def index
#static_pages = StaticPage.all
end
# GET /static_pages/1
# GET /static_pages/1.json
def show
end
# GET /static_pages/new
def new
#static_page = StaticPage.new
end
# GET /static_pages/1/edit
def edit
#static_page = StaticPage.find_by_slug(params[:slug])
end
# POST /static_pages
# POST /static_pages.json
def create
#static_page = StaticPage.new(static_page_params)
respond_to do |format|
if #static_page.save
format.html { redirect_to #static_page, notice: 'Static page was successfully created.' }
format.json { render :show, status: :created, location: #static_page }
else
format.html { render :new }
format.json { render json: #static_page.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /static_pages/1
# PATCH/PUT /static_pages/1.json
def update
respond_to do |format|
if #static_page.update(static_page_params)
format.html { redirect_to #static_page, notice: 'Static page was successfully updated.' }
format.json { render :show, status: :ok, location: #static_page }
else
format.html { render :edit }
format.json { render json: #static_page.errors, status: :unprocessable_entity }
end
end
end
# DELETE /static_pages/1
# DELETE /static_pages/1.json
def destroy
#static_page.destroy
respond_to do |format|
format.html { redirect_to static_pages_url, notice: 'Static page was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_static_page
#static_page = StaticPage.find_by_slug(params[:slug])
end
# Never trust parameters from the scary internet, only allow the white list through.
def static_page_params
params.require(:static_page).permit(:title, :permalink, :content, :tags, :author, :date)
end
end
Here is the route:
Rails.application.routes.draw do
resources :static_pages, except: [:show, :delete, :update]
devise_for :users
mount Bootsy::Engine => '/bootsy', as: 'bootsy'
get 'profile' => "users#profile"
root 'indexes#index'
get ':slug', to: 'static_pages#show'
get ':slug', to: 'static_pages#delete'
get ':slug/edit', to: 'static_pages#update'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Here is the form where the error keeps poping up on form.html.haml:
= simple_form_for(#static_page) do |f|
= f.error_notification
.form-inputs
= f.input :title
= f.input :permalink
.bootsy_text_area
= f.bootsy_area :content, :class => 'form-control', rows: 12
= f.input :tags
= f.input :author
= f.input :date
.form-actions
= f.button :submit
In your routes you have:
get ':slug/edit', to: 'static_pages#update'
Where you're sending a GET request to your update action, rather than your edit action.
Change that to:
get ':slug/edit', to: 'static_pages#edit'
You're also setting the same get :slug route to two different actions as well. The one pointing to the destroy action should be a DELETE request rather than a GET request.
One more thing, you can remove #static_page = StaticPage.find_by_slug(params[:slug]) from your controller edit action, since you're already setting the #static_page variable in your set_static_page in your before_action.
I am getting a NoMethodError (undefined method `id' for nil:NilClass) when I'm trying to create an article from my rails frontend site. I have a rails backend site which is where I have my rails API using model serializers and then I also have a rails frontend site which connects to the rails API using activeresource.
Frontend site form:
<form action="/users/articles" method="post">
<input name="authenticity_token" value="<%= form_authenticity_token %>" type="hidden">
<div class="form-group">
<%= label_tag 'article[title]', "name" %>
<input type="text" name="article[title]" required>
</div>
<div class="form-group">
<%= label_tag "article[content]", "E-Mail" %>
<input type="text" name= "article[content]" required>
</div>
<div class="form-group">
<%= label_tag "article[tags]", "Telephone" %>
<input type="text" name= "article[tags]" required>
</div>
<input type="submit">
<% if #errors %>
<ul class="list-unstyled">
<%#errors.each do |error|%>
<li class="has-error"><%=error%></li>
<% end -%>
</ul>
<% end %>
</form>
Frontend /users/ articles controller:
require 'rubygems'
require 'httparty'
module Users
class ArticlesController < UsersController
# GET /articles/new
# GET /articles/new.json
def new
#article = Article.new
end
# GET /articles/1/edit
def edit
#article = Article.find(params[:id])
end
# POST /articles
# POST /articles.json
def create
#response = HTTParty.post("http://localhost:3000/users/articles/",
:body => { :title => params[:article][:title],
:content => params[:article][:content],
:tags => params[:article][:tags]
}.to_json,
:headers => { 'Content-Type' => 'application/json' } )
end
# PUT /articles/1
# PUT /articles/1.json
def update
#article = Article.find(params[:id])
#article.user_id = current_user.id
respond_to do |format|
if #article.update(article_params)
format.html { redirect_to #article, notice: 'Article was successfully updated.' }
format.json { render :show, status: :ok, location: #article }
else
format.html { render :edit }
format.json { render json: #article.errors, status: :unprocessable_entity }
end
end
end
end
end
Error in Terminal From Backend site:
Started POST "/users/articles/" for ::1 at 2016-06-21 13:26:16 +0200
Processing by Users::ArticlesController#create as HTML
Parameters: {"title"=>"frgr", "content"=>"grgrg", "tags"=>"rgr", "article"=>{"title"=>"frgr", "tags"=>"rgr", "content"=>"grgrg"}}
Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `id' for nil:NilClass):
app/controllers/users/articles_controller.rb:52:in `create'
Article Model:
require 'active_resource'
class Article < ActiveResource::Base
self.site = "http://localhost:3000"
end
Routes File:
Rails.application.routes.draw do
resources :users#, only: [:show]
resources :articles
namespace :users do
resources :articles
end
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
The path in your create action:
#response = HTTParty.post("http://localhost:3000/users/articles/"
It does not include user id in it, hence its throwing nil for id error. The path should be:
#response = HTTParty.post("http://localhost:3000/users/user_id/articles/"
where user_id is the id of the user i.e.,it will look as below:
#response = HTTParty.post("http://localhost:3000/users/5/articles/"
I'm getting a strange reaction to my 'destroy' method. I get this error when trying to destroy a project:
Unknown action
The action '5' could not be found for ProjectsController
I figured out when when I change my routes.rb file from resources :projects (plural) to resources :project (singular), the destroy action works as it should (and returns to the index) but then my show method works but update and new methods throw undefined methodprojects_path'` errors. Why is this happening??
class ProjectsController < ApplicationController
def index
#projects = Project.sorted
end
def show
#project = Project.find(params[:id])
end
def new
#project = Project.new
#project_count = Project.count + 1
end
def create
# Instantiate a new object using form parameters
#project = Project.new(project_params)
# Save the object
if #project.save
# If save succeeds, redirect to the index action
flash[:notice] = "Project created successfully."
redirect_to(:action => 'index')
else
# If save fails, redisplay the form so user can fix problems
#project_count = Project.count + 1
render('new')
end
end
def edit
#project = Project.find(params[:id])
#project_count = Project.count
end
def update
#project = Project.find(params[:id])
if #project.update_attributes(project_params)
flash[:notice] = "Project updated successfully."
redirect_to(:action => 'show', :id => #project.id)
else
#project_count = Project.count
render('edit')
end
end
def delete
#project = Project.find(params[:id])
end
def destroy
project = Project.find(params[:id])
project.destroy
flash[:notice] = "Project '#{project.name}' destroyed successfully."
redirect_to(:action => 'index')
end
private
def project_params
params.require(:project).permit(:name, :financing, :visible, :position)
end
end
routes.rb file:
Rails.application.routes.draw do
root :to => 'projects#index'
resources :projects
match ':controller(/:action(/:id))', :via => [:get, :post]
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Exampl
e resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Delete.html.erb page:
<% #page_title = "Delete Project" %>
<%= link_to("<< Back to List", {:action => 'index'}, :class => 'back-link') %>
<div class="project destroy">
<h2>Delete Projects</h2>
<%= form_for(:project, :url => {:action => 'destroy', :id => #project.id}) do |f| %>
<p>Are you sure you want to permanently delete this project?</p>
<p class="reference-name"><%= #project.name %></p>
<div class="form-buttons">
<%= submit_tag("Delete Project") %>
</div>
<% end %>
</div>
[UPDATE]
Another interesting update. I messed around with destroy and changed the controller to:
def delete
#project = Project.find(params[:id])
#project.destroy
end
def destroy
project = Project.find(params[:id])
project.destroy
flash[:notice] = "Project '#{project.name}' destroyed successfully."
redirect_to(:action => 'index')
end
I did this to see if it was an issue with the destroy method. It does destroy the project, and still returns the delete page which causes the same error, but it does destroy it.
Though you are doing a couple of unconventional stuff like having delete.html.erb (objects are deleted from the show view page), I'm going to address your direct question.
you said:
"when I change my routes.rb file from resources :projects (plural) to resources :project (singular), the destroy action works as it should (and returns to the index) but then my show method works but update and new methods throw undefined method projects_path'` errors. Why is this happening??"
you have understand every time you change your routes, you have to modify the helper paths in your views.
example: when you had resources :projects, you helper methods were (run rake db:migrate)
projects_path GET /projects(.:format) projects#index
POST /projects(.:format) projects#create
new_project_path GET /projects/new(.:format) projects#new
edit_project_path GET /projects/:id/edit(.:format) projects#edit
project_path GET /projects/:id(.:format) projects#show
PATCH /projects/:id(.:format) projects#update
PUT /projects/:id(.:format) projects#update
DELETE /projects/:id(.:format) projects#destroy
So at this point, projects_path was working because as you can see above, projects_path is there.
when you changed your routes to resources :project(singular), your helper paths change as well. run rake db:migrate to see them:
project_index_path GET /project(.:format) project#index
POST /project(.:format) project#create
GET /project/new(.:format) project#new
GET /project/:id/edit(.:format) project#edit
GET /project/:id(.:format) project#show
PATCH /project/:id(.:format) project#update
PUT /project/:id(.:format) project#update
DELETE /project/:id(.:format) project#destroy
As you can see the helper path that maps to project#index is project_index_path.
So I'm guessing in your edit.html.erb (or somewhere else) you have the old code: projects_path and so you are getting undefined method projects_path because the helper no longer exist. The correct helper method in this case, is project_index_path.
Hi does anyone know what is causing this error.
I'm new to rails but am guessing it has something to do with bootstrap. However, I have no idea how to fix it and I've been trying the last 2 hours.
Error
Template is missing
Missing template authentication/account_settings, application/account_settings with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in: * "/home/action/workspace/PAW/app/views" * "/home/action/.rvm/gems/ruby-2.1.1/gems/twitter-bootstrap-rails-2.2.8/app/views"
I have account_settings defined in the authentication controller
authentication_controller.rb
# Class written by Alan Dunne after following tutorials by Marc Clifton [Available # http://www.codeproject.com/Articles/575551/User-Authentication-in-Ruby-on-Rails#AdministratingUsers78]
class AuthenticationController < ApplicationController
def sign_in
#user = User.new
end
def login
username_or_email = params[:user][:username]
password = params[:user][:password]
if username_or_email.rindex('#')
email=username_or_email
user = User.authenticate_by_email(email, password)
else
username=username_or_email
user = User.authenticate_by_username(username, password)
end
if user
session[:user_id] = user.id
flash[:notice] = 'Welcome'
redirect_to '/home'
else
flash.now[:error] = 'Unknown user. Please check your username and password.'
# Assign user to instance variable for the `sign_in` view!
#user = User.new(params[:user])
render :action => "sign_in"
end
end
def signed_out
session[:user_id] = nil
flash[:notice] = "You have been signed out."
end
def new_user
#user = User.new
end
def register
#user = User.new(params[:user])
if #user.valid?
#user.save
session[:user_id] = #user.id
flash[:notice] = 'Welcome.'
redirect_to :root
else
render :action => "new_user"
end
end
def account_settings
#user = current_user
end
def set_account_info
old_user = current_user
# verify the current password by creating a new user record.
#user = User.authenticate_by_username(old_user.username, params[:user][:password])
# verify
if #user.nil?
#user = current_user
#user.errors[:password] = "Password is incorrect"
render :action => "account_settings"
else
# update the user with any new username and email
#user.update(params[:user])
# Set the old email and username, which is validated only if it has changed.
#user.previous_email = old_user.email
#user.previous_username = old_user.username
if #user.valid?
# If there is a new_password value, then we need to update the password.
#user.password = #user.new_password unless #user.new_password.nil? || #user.new_password.empty?
#user.save
flash[:notice] = 'Account settings have been changed'
redirect_to :root
else
render :action => "account_settings"
end
end
end
end
routes.rb
Rails.application.routes.draw do
resources :match_picks
resources :matches
root :to=>"home#index"
get "sign_in" => "authentication#sign_in"
# get "home" => "authentication#login"
# get "instructions" => 'home'
get "signed_out" => "authentication#signed_out"
get "new_user" => "authentication#new_user"
post "sign_in" => "authentication#login"
put "sign_in" => "authentication#login"
post "new_user" => "authentication#register"
put "new_user" => "authentication#register"
get "admin_users" => "admin#users"
delete "user/:id" => "admin#delete_user", :as => "user"
get "admin_users" => "authentication#admin_users"
get '/home', to: 'home#home'
get '/instructions', to: 'home#instructions'
get '/blocks', to: 'home#blocks'
post "match/create-match-pick" => "matches#create_match_pick", :as => :create_match_pick
get "account_settings" => "authentication#account_settings"
put "account_settings" => "authentication#set_account_info"
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
The controller method:
def account_settings
#user = current_user
end
Is looking to render a template file located at:
views/authentication/account_settings.html.erb (or .jbuilder, etc)
Does that file exist? If not you should create it.
Your error says you're expecting a file named: account_settings.html.erb
Go to: app/views/authentication/, and search for the file.
You are missing a view.
It should be this file:/app/views/authentication/account_settings.html.erb