I have the following new method in ruby ββon a rails application:
def new if cookies[:owner].empty? cookies[:owner] = SecureRandom.hex end @movie = Movie.new @movie.owner = cookies[:owner] end
In principle, each new user should be issued a code that identifies them (although only cookies). Therefore, when a user creates a movie, the cookie created is saved in the owner field.
So, two problems:
Use empty? method, when I remove the cookie from the browser, returns a undefined method empty? 'for nil: NilClass`
When I do have a cookie already set in the browser and then make a movie, is the cookie [: owner] different from the @ movie.owner code?
source share