When a user creates a password update action is hit.
module Users
class PasswordController < ApplicationController
skip_before_action :authenticate_user!
before_action :set_user
def setup
render file: "#{Rails.root}/public/404" unless #user&.sign_in_count&.zero?
end
def update
if #user.update_attributes(password_params)
sign_in(:user, #user)
redirect_to root_path, notice: 'Setup complete'
else
flash[:alert] = errors(#user)
render :setup
end
end
private
def password_params
params.require(:user).permit(:password, :password_confirmation)
end
def set_user
#user = User.find_by(confirmation_token: params[:token])
end
end
end
When the update action is hit.
This is what the console shows
Started PATCH "/users/password/wynEjv-E7uFp44EcwjbS" for ::1 at 2017-02-07 12:33:01 +1000
Processing by Users::PasswordController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"vIyPtidsM1GDNLh3n7gDDB2HzvR0QEEwAAvfMybNRn0/t4em4StiUVDyKwLC9i1OThoYguEae4T+xqLttjt1Pw==", "email"=>"test04#example.com", "user"=>{"password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Continue", "token"=>"wynEjv-E7uFp44EcwjbS"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = $1 LIMIT $2 [["confirmation_token", "wynEjv-E7uFp44EcwjbS"], ["LIMIT", 1]]
(0.1ms) BEGIN
SQL (0.5ms) UPDATE "users" SET "encrypted_password" = $1, "updated_at" = $2 WHERE "users"."id" = $3 [["encrypted_password", "$2a$11$o5wmmxnCv.rlPha52GR0IOG4tbhEJYNNF9tctcSLDMS/dvLAU0hXq"], ["updated_at", 2017-02-07 02:33:01 UTC], ["id", 9]]
(1.0ms) COMMIT
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 9], ["LIMIT", 1]]
(0.1ms) BEGIN
(0.2ms) COMMIT
Completed 401 Unauthorized in 129ms (ActiveRecord: 2.5ms)
Does anyone know why the sign_in method isn't working here?
I used it on few apps and it worked then.
Thank you for any help in advance.
You can use it like this
#user.update_with_password(password_params)
sign_in #user, :bypass => true
Hope it will work for you as it worked for me!
Related
I am sending an AJAX request from my frontend to rails for a patch request but getting an action cannot be found error.
So far, I have double checked my routes and controller to make sure there were no mistakes. My create action is working fine which is in the users controller. Ive also double checked my AJAX request to make sure it is going to the correct url. My AJAX request is also for an AWS upload if that helps.
Here are my routes
namespace :api, defaults: {format: :json} do
resources :users, only: [:create, :update, :show]
resource :session, only: [:create, :destroy, :show]
end
root "static_pages#root"
end
here is my controller with the update action
class Api::UsersController < ApplicationController
def create
#user = User.new(user_params)
if #user.save
login(#user)
render "api/users/show"
else
render json: #user.errors.full_messages, status: 422
end
def show
#user = User.find(params[:id])
render "api/users/show"
end
def update
#user = User.find(params[:id])
if #user.update_attributes(user_params)
render "api/users/show"
else
render json: #user.errors.full_messages
end
end
end
def user_params
params.require(:user).permit(:email, :password, :first_name, :last_name, :DOB, :gender, :prof_photo, :cover_photo)
end
end
Update: ajax request for AWS user photo upload.
export const updateUser = (userId, formData) => {
return $.ajax({
method: "PATCH",
url: `api/users/${userId}`,
data: formData,
contentType: false,
processData: false
})
}
Finally here are the server logs
AbstractController::ActionNotFound - The action 'update' could not be found for Api::UsersController:
Started GET "/" for ::1 at 2019-10-06 07:49:03 -0400
Processing by StaticPagesController#root as HTML
Rendering static_pages/root.html.erb within layouts/application
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."session_token" = $1 LIMIT $2 [["session_token", "mRbshUiTIXjVd3LpZSiWvA"], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:10
ActiveStorage::Attachment Load (0.7ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 2], ["record_type", "User"], ["name", "prof_photo"], ["LIMIT", 1]]
↳ app/views/api/users/_user.json.jbuilder:3
ActiveStorage::Blob Load (1.1ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 2], ["LIMIT", 1]]
↳ app/views/api/users/_user.json.jbuilder:3
Rendered api/users/_user.json.jbuilder (7.2ms)
Rendered static_pages/root.html.erb within layouts/application (13.8ms)
Completed 200 OK in 93ms (Views: 86.5ms | ActiveRecord: 2.8ms)
Started PATCH "/api/users/2" for ::1 at 2019-10-06 07:55:37 -0400
AbstractController::ActionNotFound - The action 'update' could not be found for Api::UsersController:````
Found the rookie mistake! The end statement for create action was all the way at the bottom (hence only my create action was working) Make sure to check your end statements!
Here is the code I'm trying to use in my controller:
profiles_controller.rb:
class ProfilesController < ApplicationController
...
def update
respond_to do |format|
# assume valid data sent (I've already tested for this)
if #user.update(user_params)
# password_reset? check's parameter passed to action that a check box was
# checked (which enables/disables password/confirmation fields. If unchecked,
# fields are disabled and no password parameters are sent to this action.
# #user was set to current_user in a before_action already
# inspecting #user at this point returns the same thing as current_user here
sign_in(:user, #user) if password_reset?
# current_user is still set to #user and is valid
# after redirection current_user becomes nil
format.html {
redirect_to home_path, notice: 'Your profile was successfully updated.'
}
else
format.html { render :edit }
end
end
end
...
private
# Never trust parameters from the scary internet, only allow the white list through.
def user_params
#user_params ||= params.require(:user).permit(:first_name, :last_name, :email, :phone, :password, :password_confirmation, :reset_password)
end
def password_reset?
#user_params["reset_password"] == "1"
end
end
application_controller.rb:
class ApplicationController < ActionController::Base
...
private
...
def require_user
logger.debug "IN REQUIRE_USER, CURRENT_USER IS: #{current_user.inspect}"
unless current_user
store_location
redirect_to new_user_session_url, notice: "That url doesn't exist."
return false
end
end
def require_admin
# this line will actually log a user in
#sign_in(:user, User.first) unless current_user
logger.debug "IN REQUIRE_ADMIN, CURRENT_USER IS: #{current_user.inspect}"
unless current_user && current_user.is_admin?
redirect_to(home_path, notice: "That url doesn't exist.") and return false
end
end
...
end
development.log:
Started PATCH "/profile" for 127.0.0.1 at 2019-05-28 10:38:45 -0700
Processing by ProfilesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"....", "user"=>{....}, "commit"=>"Update Profile"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:47
IN REQUIRE_USER, CURRENT_USER IS: #<User id: 1 ....>
(0.1ms) begin transaction
↳ app/controllers/profiles_controller.rb:16
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER(?) AND "users"."id" != ? LIMIT ? [["email", "...."], ["id", 1], ["LIMIT", 1]]
↳ app/controllers/profiles_controller.rb:16
User Update (0.3ms) UPDATE "users" SET "encrypted_password" = ?, "updated_at" = ? WHERE "users"."id" = ? [["encrypted_password", "$2a$11...."], ["updated_at", "2019-05-28 17:38:45.346414"], ["id", 1]]
↳ app/controllers/profiles_controller.rb:16
(2.3ms) commit transaction
↳ app/controllers/profiles_controller.rb:16
PASSWORDS PASSED IN SO USER PASSWORD CHANGE OCCURRED
REDIRECTING TO HOME PATH
Redirected to http://localhost:3000/admin
Completed 302 Found in 121ms (ActiveRecord: 3.2ms)
Started GET "/admin" for 127.0.0.1 at 2019-05-28 10:38:45 -0700
Processing by Admin::PagesController#index as HTML
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:65
IN REQUIRE_ADMIN, CURRENT_USER IS: nil
Redirected to http://localhost:3000/
Filter chain halted as :require_admin rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.2ms)
Started GET "/" for 127.0.0.1 at 2019-05-28 10:38:45 -0700
Processing by PagesController#index as HTML
Rendering pages/index.html.erb within layouts/application
Rendered pages/index.html.erb within layouts/application (0.7ms)
Rendered application/_navigation.html.erb (1.7ms)
Rendered application/_alert.html.erb (0.3ms)
Completed 200 OK in 1152ms (Views: 1151.2ms | ActiveRecord: 0.0ms)
I've searched around and seen by_pass: true being passed to sign_in but that doesn't help. I've also tried #current_user = #user once I've signed the user in (#current_user is the direct instance variable for the Devise controller btw) and that does not help either.
Any ideas?
Devise ignores signin if the user is already signed in, try:
if #user.saved_change_to_encrypted_password? # for rails 5+, for previous - .encrypted_password_changed?
sign_in #user, force: true
end
You can signin new session if the user is already signed in.
Devise said
# Sign in a user bypassing the warden callbacks and stores the user
# straight in session. This option is useful in cases the user is
# signed in, but we want to refresh the credentials in session.
Please use like below one.
bypass_sign_in(#user)
I'm using the Best In Place Gem to do inline edits on a table of Tasks that has a nested attribute for Storeorder, however when I try to edit a Storeorder attribute using the instructions provided in this post, I get a 204 No Content error thrown at me. I wonder if it has to do with the first transaction beginning before the 'Storeorder Load' happens? In all non-nested BIP updates, it does the UPDATE within the first "begin transaction" call, whereas here it's still loading the Storeorder. The parameters are 100% correct as far as I can tell. See code,
Started PUT "/tasks/3" for 104.200.151.54 at 2017-02-05 18:08:24 +0000
Processing by TasksController#update as JSON
Parameters: {"task"=>{"storeorder_attributes"=>{"id"=>"3", "activity"=>"Shipped"}}, "authenticity_token"=>"D2c3ddoIC220rkPE5i7U+EGiwSrdCq7s8vdFY8VEQTaTMqetuBo8SJX9+Wabl+Bh6A6d49Pt/Omp4E/nq/udQA==", "id"=>"3"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 1], ["LIMIT", 1]]
Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
CACHE (0.0ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
(0.1ms) begin transaction
Storeorder Load (0.2ms) SELECT "storeorders".* FROM "storeorders" WHERE "storeorders"."task_id" = ? LIMIT ? [["task_id", 3], ["LIMIT", 1]]
(0.1ms) commit transaction
(0.1ms) begin transaction
(0.1ms) commit transaction
Completed 204 No Content in 10ms (ActiveRecord: 1.0ms)
tasks_controller.rb -->
class TasksController < ApplicationController
before_action :set_task, only: [:show, :edit, :update, :destroy]
def update
#task = Task.find(params[:id])
respond_to do |format|
if #task.update(task_params)
format.html { redirect_to #task, notice: 'Task was successfully updated.' }
format.json { respond_with_bip(#task) }
else
format.html { render :edit }
format.json { respond_with_bip(#task) }
end
end
end
private
def set_task
#task = Task.find(params[:id])
end
def task_params
params.require(:task).permit!
end
end
task.rb -->
class Task < ApplicationRecord
has_one :storeorder, :dependent => :destroy
accepts_nested_attributes_for :storeorder, :reject_if => lambda { |a| a[:store_id].blank? }, :allow_destroy => true
end
storeorder.rb -->
class Storeorder < ApplicationRecord
belongs_to :task
end
dashboard.html.erb -->
<td><%= best_in_place task.storeorder, :activity,
url: task_path(task.id),
param: "task[storeorder_attributes][id]=#{task.storeorder.id}&task[storeorder_attributes]",
as: :select,
collection: [["Pending Shipment", "Pending Shipment"], ["Shipped", "Shipped"], ["Cancelled", "Cancelled"], ["Pending Further Action", "Pending Further Action"]], %>
</td>
inner HTML code -->
<span
data-bip-type="select"
data-bip-attribute="activity"
data-bip-collection="[["Pending Shipment","Pending Shipment"],["Shipped","Shipped"],["Cancelled","Cancelled"],["Pending Further Action","Pending Further Action"]]"
data-bip-inner-class="form-control"
data-bip-object="task[storeorder_attributes][id]=3&task[storeorder_attributes]"
data-bip-original-content="Pending Shipment"
data-bip-skip-blur="false"
data-bip-url="/tasks/3"
data-bip-value="Shipped"
class="best_in_place form-control"
id="best_in_place_storeorder_3_activity">
Shipped
</span>
I can't see what I could possibly be missing that causes this error. It's imperative that I'm allowed to do inline edits to keep the workflow consistent, otherwise I'm open to alternative suggestions since I know BIP doesn't have nested attribute editing within their scope by default.
:reject_if => lambda { |a| a[:store_id].blank? }
Don't see any store_id being passed in params.
I've been working with the acts_as_commentable_with_threading gem and I can't get the comments to save.
My controller:
class CommentsController < ApplicationController
def create
#comment_hash = params[:comment]
#obj = #comment_hash[:commentable_type].constantize.find(#comment_hash[:commentable_id])
# Not implemented: check to see whether the user has permission to create a comment on this object
#comment = Comment.build_from(#obj, current_user, #comment_hash[:body])
if #comment.save
flash[:notice] = "New comment saved!!!!!"
redirect_to status_path(#obj)
#redirect_to profiles_path(current_user)
else
flash[:alert] = "didn't save"
redirect_to status_path(#obj)
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def comment_params
params.require(:comment,:commentable_id,:commentable_type, :user_id, :body)
end
end
When I check the development log I can see that the values in the hash are all populated and I can see the transaction start the save, but it is immediately rolled back.
Started POST "/comments" for 127.0.0.1 at 2014-01-30 10:47:54 +0100
Processing by CommentsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"ojRIz0hj0m8BL613Q9W4DHkYNZqO8eeMvR2gEM6Qhp8=", "comment"=> {"body"=>"test comment", "commentable_id"=>"52", "commentable_type"=>"Status"}, "commit"=>"Submit"}
[1m[35mStatus Load (0.1ms)[0m SELECT "statuses".* FROM "statuses" WHERE "statuses"."id" = ? ORDER BY created_at DESC LIMIT 1 [["id", "52"]]
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = 6 ORDER BY "users"."id" ASC LIMIT 1[0m
[1m[35m (0.1ms)[0m begin transaction
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
Redirected to http://localhost:3000/statuses/52
Completed 302 Found in 5ms (ActiveRecord: 0.6ms)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I've got three models set up. Users, guides, and comments. Users have many guides and comments. Guides belong to users and have many comments. Comments belong to users and guides.
When I run Comment.last.user in the console, it returns the information pertaining to the user. However, when I run Comment.last.guide in the console, it returns nil. Something is going wrong with the creation of the comment.
The models all have the classic has_many and belongs_to relationships set up, so I'll omit those from here. Here is the comments controller:
class CommentsController < ApplicationController
before_action :set_comment, only: [:show, :edit, :update, :destroy]
# GET /comments
# GET /comments.json
def index
#comments = Comment.all
end
# GET /comments/1
# GET /comments/1.json
def show
end
# GET /comments/new
def new
#comment = Comment.new
end
# GET /comments/1/edit
def edit
end
# POST /comments
# POST /comments.json
def create
#comment = current_user.comments.build(comment_params)
respond_to do |format|
if #comment.save
format.html { redirect_to :back, notice: 'Comment was successfully created.' }
format.json { render action: 'show', status: :created, location: #comment }
else
format.html { render action: 'new' }
format.json { render json: #comment.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /comments/1
# PATCH/PUT /comments/1.json
def update
respond_to do |format|
if #comment.update(comment_params)
format.html { redirect_to #comment, notice: 'Comment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: #comment.errors, status: :unprocessable_entity }
end
end
end
# DELETE /comments/1
# DELETE /comments/1.json
def destroy
#comment.destroy
respond_to do |format|
format.html { redirect_to comments_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_comment
#comment = Comment.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def comment_params
params.require(:comment).permit(:body, :user_id, :guide_id)
end
end
Here is the comments migration:
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.text :body
t.references :user, index: true
t.references :guide, index: true
t.timestamps
end
end
end
Log output when creating comment:
Started POST "/comments" for 127.0.0.1 at 2014-01-08 08:30:54 -0500
Processing by CommentsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"D2BvBIgU+tniZvr2NgQE/TpHY6J2xHOUm701jqTcJ9A=", "comment"=>{"body"=>"NitinJ Sample Comment", "user_id"=>"some value", "guide_id"=>"some value"}, "commit"=>"Create Comment"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
(0.1ms) begin transaction
SQL (21.7ms) INSERT INTO "comments" ("body", "created_at", "guide_id", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?) [["body", "NitinJ Sample Comment"], ["created_at", Wed, 08 Jan 2014 13:30:54 UTC +00:00], ["guide_id", 0], ["updated_at", Wed, 08 Jan 2014 13:30:54 UTC +00:00], ["user_id", 1]]
(21.0ms) commit transaction
Redirected to http://localhost:3000/guides/1-attack
Completed 302 Found in 53ms (ActiveRecord: 43.1ms)
Started GET "/guides/1-attack" for 127.0.0.1 at 2014-01-08 08:30:54 -0500
Processing by GuidesController#show as HTML
Parameters: {"id"=>"1-attack"}
Guide Load (0.2ms) SELECT "guides".* FROM "guides" WHERE "guides"."id" = ? LIMIT 1 [["id", "1-attack"]]
CACHE (0.0ms) SELECT "guides".* FROM "guides" WHERE "guides"."id" = ? LIMIT 1 [["id", "1-attack"]]
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
Comment Load (0.2ms) SELECT "comments".* FROM "comments" WHERE "comments"."guide_id" = ? [["guide_id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Rendered comments/_form.html.erb (6.6ms)
Rendered guides/show.html.erb within layouts/application (18.9ms)
DEPRECATION WARNING: Calling #sum with a block is deprecated and will be removed in Rails 4.1. If you want to perform sum calculation over the array of elements, use `to_a.sum(&block)`. (called from _app_views_layouts__navbar_html_erb__2351226726967046587_2202447400 at /Users/DylanRichards/Desktop/runescapeguides/app/views/layouts/_navbar.html.erb:35)
Guide Load (0.2ms) SELECT "guides".* FROM "guides" WHERE "guides"."user_id" = ? [["user_id", 1]]
(0.2ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = ? AND "votes"."votable_type" = ? AND "votes"."vote_flag" = 't' AND "votes"."vote_scope" IS NULL [["votable_id", 1], ["votable_type", "Guide"]]
(0.2ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = ? AND "votes"."votable_type" = ? AND "votes"."vote_flag" = 'f' AND "votes"."vote_scope" IS NULL [["votable_id", 1], ["votable_type", "Guide"]]
Rendered layouts/_navbar.html.erb (7.4ms)
Completed 200 OK in 54ms (Views: 47.8ms | ActiveRecord: 1.5ms)
Second log output
Started POST "/guides/1-attack/comments" for 127.0.0.1 at 2014-01-08 08:52:29 -0500
Processing by CommentsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"D2BvBIgU+tniZvr2NgQE/TpHY6J2xHOUm701jqTcJ9A=", "comment"=>{"body"=>"Another sample NitinJ comment.", "user_id"=>"some value", "guide_id"=>"some value"}, "commit"=>"Create Comment", "guide_id"=>"1-attack"}
Completed 500 Internal Server Error in 69ms
NoMethodError (undefined method `[]=' for nil:NilClass):
app/controllers/comments_controller.rb:27:in `create'
Rendered /Users/DylanRichards/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.0ms)
Rendered /Users/DylanRichards/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.7ms)
Rendered /Users/DylanRichards/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.5ms)
Rendered /Users/DylanRichards/.rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (21.7ms)
try this <%= f.association :guide, :as => :hidden, :input_html => { :value => #guide.id }%>