0
votes

Problem solved thanks to @skipchris (https://twitter.com/skipchris) Using debugger we found a spelling mistake. The error report didn't make much sense but i learned plenty investigating the problem!

I've spent last night and this morning trying to find a solution but i'm new to rails. From what i've read so far it think the problem is to do with association. I created a Pin without a User (association error?) and so there is an error with routing i.e something to do with Devise?

When i try to create a new Pin i get this error in browser on my local server-

NoMethodError in PinsController#create

pp/controllers/pins_controller.rb:48:in block in create' app/controllers/pins_controller.rb:47:increate'

pins_controller.rb

def create

@pin = current_user.pins.new(params[:pin])

respond_to do |format|
  if @pin.save
    format.html { redirect_to @pin, notice: 'Pin was successfully created.' }
    format.json { render json: @pin, status: :created, location: @pin }
  else
    format.html { render action: "new" }
    format.json { render json: @pin.errors, status: :unprocessable_entity }
  end
end   

end

User Model (user.rb)

class User < ActiveRecord::Base

devise :database_authenticatable, :registerable, #:recoverable, :rememberable, :trackable, :validatable

attr_accessible :email, :password, :password_confirmation, :remember_me, :name

has_many :pins

end

1

1 Answers

0
votes

Yeah, I would definitely make a user model since you are trying to access current_user.pins in the methods. also do you have

resources :pins

or something similar in your routes?