I\'m developing a website using jQuery Preview to fetch the title, description or favction_url of any link.
jQuery Preview: https://github.com/embedly/jquery-preview/
In your create action you're trying to assign link_params hash as value for content which expects text.
With the call to Link.new(...) passing in attributes you are mass assigning attributes, and with Rails4 strong parameters you need to add all the attributes to the permit list that you will be mass assigning.
Update the create and link_params method definition as follows:
# app/controllers/links_controller.rb
def create
@link = Link.new(link_params)
if @link.save
redirect_to root_path
else
render :new
end
end
private
def link_params
params.require(:link).permit(:content, :title, :description, :favicon_url)
end
Update: Merge certain attributes from the parameter hash and merge them to params[:link]
# app/controllers/links_controller
private
def link_params
# Select parameters you need to merge
params_to_merge = params.select { |k, v| ['title', 'description', 'favicon_url'].include?(k) }
params.require(:link).permit(:content).merge(params_to_merge)
end