ruby - Undefined method `find_or_initialize_by_url'. Correct syntax in Rails 4? -


wondering if can me out. i'm getting "undefined method `find_or_initialize_by_url'" on sites/new.

controller below

def create   @site = site.find_or_initialize_by_url(params[:site][:url])    if @site.save     redirect_to site_path(@site)   else     redirect_to :back, :flash => {:error => @site.errors[:url]}   end 

what correct syntax

@site = site.find_or_initialize_by_url(params[:site][:url]) in rails 4?

all code taken here https://github.com/blatyo/is_it_popular

in rails 4,it should be

@site = site.find_or_initialize_by(url: params[:site][:url]) 

source: guides


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -