I am trying to make an app in Rails 4.
I use simple form with Cocoon gem.
In development mode, I have all of this working correctly, however in production mode its a big mess.
I have profile model and a qualifications model.
The associations are:
profile.rb
has_many :qualifications
accepts_nested_attributes_for :qualifications, reject_if: :all_blank, allow_destroy: true
qualification.rb
belongs_to :profile
In my profiles new form, I have:
<%= simple_form_for(#profile, multipart: true) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<div class="intpol2">
Your professional qualifications
</div>
<%= f.simple_fields_for :qualifications do |f| %>
<%= render 'qualifications/qualification_fields', f: f %>
<% end %>
</div>
<div class="row">
<div class="col-md-6">
<%= link_to_add_association 'Add a qualification', f, :qualifications, partial: 'qualifications/qualification_fields' %>
</div>
</div>
<div class="row">
In my qualifications fields new form, I have:
<div class="nested-fields">
<div class="container-fluid">
<div class="form-inputs">
<div class="row">
<div class="col-md-6">
<%= f.input :title, :label => "Your award" %>
</div>
<div class="col-md-6">
</div>
</div>
<div class="row">
<div class="col-md-6">
<%= f.input :level, collection: [ "Bachelor's degree", "Master's degree", "Ph.D", "Post Doctoral award"] %>
</div>
<div class="col-md-6">
<%= f.input :year_earned, :label => "When did you graduate?", collection: (Date.today.year - 50)..(Date.today.year) %>
</div>
</div>
<div class="row">
<div class="col-md-6">
<%= link_to_remove_association 'Remove this qualification', f %>
</div>
</div>
</div>
</div>
</div>
In development, when I click the link to add a new qualification, it reloads the profile new form, but does not reveal the qualifications field form.
I have the same setup with address model (same as qualification).
All of this works in development, but not in production.
Is there an extra step required to get this working in production?
My qualifications controller:
class QualificationsController < ApplicationController
before_action :set_qualification, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /qualifications
# GET /qualifications.json
def index
#qualifications = Qualification.all
authorize #qualifications
end
# GET /qualifications/1
# GET /qualifications/1.json
def show
end
# GET /qualifications/new
def new
#qualification = Qualification.new
authorize #qualification
end
# GET /qualifications/1/edit
def edit
end
# POST /qualifications
# POST /qualifications.json
def create
#qualification = Qualification.new(qualification_params)
authorize #qualification
respond_to do |format|
if #qualification.save
format.html { redirect_to #qualification }
format.json { render :show, status: :created, location: #qualification }
else
format.html { render :new }
format.json { render json: #qualification.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /qualifications/1
# PATCH/PUT /qualifications/1.json
def update
respond_to do |format|
if #qualification.update(qualification_params)
format.html { redirect_to #qualification }
format.json { render :show, status: :ok, location: #qualification }
else
format.html { render :edit }
format.json { render json: #qualification.errors, status: :unprocessable_entity }
end
end
end
# DELETE /qualifications/1
# DELETE /qualifications/1.json
def destroy
#qualification.destroy
respond_to do |format|
format.html { redirect_to qualifications_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_qualification
#qualification = Qualification.find(params[:id])
authorize #qualification
end
# Never trust parameters from the scary internet, only allow the white list through.
def qualification_params
params[:qualification].permit(:profile_id, :level, :title, :year_earned, :institution)
end
end
My profiles controller:
class ProfilesController < ApplicationController
before_action :set_profile, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
after_action :verify_authorized
# GET /profiles
# GET /profiles.json
def index
#profiles = Profile.all
authorize #profiles
end
# GET /profiles/1
# GET /profiles/1.json
def show
end
# GET /profiles/new
def new
#profile = Profile.new
#profile.qualifications.build
#profile.visions.build
#profile.personalities.build
#profile.addresses.build
authorize #profile
end
# GET /profiles/1/edit
def edit
end
# POST /profiles
# POST /profiles.json
def create
#profile = Profile.new(profile_params)
authorize #profile
respond_to do |format|
if #profile.save
format.html { redirect_to #profile }
format.json { render :show, status: :created, location: #profile }
else
format.html { render :new }
format.json { render json: #profile.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /profiles/1
# PATCH/PUT /profiles/1.json
def update
respond_to do |format|
if #profile.update(profile_params)
format.html { redirect_to #profile }
format.json { render :show, status: :ok, location: #profile }
else
format.html { render :edit }
format.json { render json: #profile.errors, status: :unprocessable_entity }
end
end
end
# DELETE /profiles/1
# DELETE /profiles/1.json
def destroy
#profile.destroy
respond_to do |format|
format.html { redirect_to profiles_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_profile
#profile = Profile.find(params[:id])
authorize #profile
end
# Never trust parameters from the scary internet, only allow the white list through.
def profile_params
params.require(:profile).permit(:user_id, :title, :hero, :overview, :research_interest, :occupation, :external_profile,
:working_languages, :tag_list,
user_attributes: [:avatar],
personality_attributes: [:average_day, :fantasy_project, :preferred_style],
vision_attributes: [:long_term, :immediate_challenge],
qualifications_attributes: [:id, :level, :title, :year_earned, :institution, :_destroy],
addresses_attributes: [:id, :unit, :building, :street_number, :street, :city, :region, :zip, :country, :latitude, :longitude, :_destroy] )
end
end
This was solved when I precompiled my assets
Related
I'm creating a form in which I create related records, so far it works pretty well, it creates the nested records but when I create them it shows in the same form the related records created before, I just need to save records and not show the ones created in the textfields, how can I do that? this is my form
<%= form_with(model: drugs_device, local: true, html: {class: "formulario_validado"}) do |form| %>
<div class="form-row">
<div class="form-group col-md-6">
<%= form.label :abbreviation,"Código / ATC" %>
<%= form.text_field :abbreviation, class:"form-control", required: "true"%>
</div>
<%=form.fields_for :detail_drugs_devices do |fd| %>
<div class="form-row">
<div class="form-group col-md-3">
<%= fd.label :drug_concentration,"Concentration:" %>
<%= fd.text_field :drug_concentration, class:"form-control" %>
</div>
<div class="form-group col-md-3">
<%= fd.label :route_id,"Vía de administración" %>
<%= fd.select :route_id, options_for_select(#routes.map{|e|[e.description, e.id]}), {:prompt => "Por favor seleccione"}, {:class => "form-control"} %>
</div>
</div>
<%end%>
<div class="row">
<div class="col-md-4 offset-md-8 ">
<%= submit_tag "Guardar", class: "btn btn-primary"%>
</div>
</div>
</div>
<%end%>
my model drugs_device:
class DrugsDevice < ApplicationRecord
belongs_to :group
has_many :detail_drugs_devices
accepts_nested_attributes_for :detail_drugs_devices, reject_if: proc { |attributes| attributes['pharmaceutical_form_id'].blank?}
end
my model DetailDrugsDevice
class DetailDrugsDevice < ApplicationRecord
belongs_to :drugs_device
belongs_to :pharmaceutical_form
belongs_to :unit_size
belongs_to :route
end
my controller:
class DrugsDevicesController < ApplicationController
before_action :set_drugs_device, only: [:show, :edit, :update, :destroy]
# GET /drugs_devices
# GET /drugs_devices.json
def index
##drugs_devices = DrugsDevice.Busqueda_general(params).paginate(page: params[:page]).per_page(3)
#drugs_devices = DrugsDevice.all.paginate(page: params[:page]).per_page(3)
end
# GET /drugs_devices/1
# GET /drugs_devices/1.json
def show
end
# GET /drugs_devices/new
def new
#drugs_device = DrugsDevice.new
#drugs_device.detail_drugs_devices.build
#grupos = Group.all
#pharmaceutical_forms = PharmaceuticalForm.all
#unit_sizes = UnitSize.all
#routes = Route.all
end
# GET /drugs_devices/1/edit
def edit
#drugs_device.detail_drugs_devices.build
#grupos = Group.all
#pharmaceutical_forms = PharmaceuticalForm.all
#unit_sizes = UnitSize.all
#routes = Route.all
end
# POST /drugs_devices
# POST /drugs_devices.json
def create
#drugs_device = DrugsDevice.new(drugs_device_params)
respond_to do |format|
if #drugs_device.save
format.html { redirect_to edit_drugs_device_path(#drugs_device), notice: 'Drugs device was successfully created.' }
format.json { render :show, status: :created, location: #drugs_device }
else
format.html { render :new }
format.json { render json: #drugs_device.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /drugs_devices/1
# PATCH/PUT /drugs_devices/1.json
def update
respond_to do |format|
if #drugs_device.update(drugs_device_params)
format.html { redirect_to edit_drugs_device_path(#drugs_device), notice: 'Drugs device was successfully updated.' }
format.json { render :show, status: :ok, location: #drugs_device }
else
format.html { render :edit }
format.json { render json: #drugs_device.errors, status: :unprocessable_entity }
end
end
end
# DELETE /drugs_devices/1
# DELETE /drugs_devices/1.json
def destroy
#drugs_device.destroy
respond_to do |format|
format.html { redirect_to drugs_devices_url, notice: 'Drugs device was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_drugs_device
#drugs_device = DrugsDevice.find(params[:id])
end
# Only allow a list of trusted parameters through.
def drugs_device_params
params.require(:drugs_device).permit(:group_id, :atc, :abbreviation, :cientific_name, :stated_at, detail_drugs_devices_attributes: [:pharmaceutical_form_id, :unit_size_id, :route_id, :drug_concentration, :id])
end
end
I'm currently trying to add a collection_select of ranches to my staff
And I saw that it's better to create an extra table to make this association.
And I follow some tutorial, but is not working on my side
This is my code :
Staffs/_form :
<%= form_for(#staff) do |f| %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
<%= fields_for(#staff_ranch) do |x| %>
<div class="field">
<%= x.collection_select(:ranch_id, #all_ranch, :id, :name, { }, {:multiple => true}) %>
</div>
<%end%>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
My models :
- Ranch :
has_many :ranchstaffs
has_many :staffs, :through => :ranchstaffs
- Staff :
has_many :ranchstaffs
has_many :ranches, :through => :ranchstaffs
-Ranchstaff :
belongs_to :ranch
belongs_to :staff
Staff controller :
class StaffsController < ApplicationController
before_action :set_staff, only: [:show, :edit, :update, :destroy]
# GET /ranches
# GET /ranches.json
def index
#staffs = current_user.staffs
end
# GET /ranches/1
# GET /ranches/1.json
def show
end
# GET /ranches/new
def new
#staff = Staff.new
#all_ranch = current_user.ranches
#staff_ranch = #staff.ranchstaffs.build
end
# GET /ranches/1/edit
def edit
end
# POST /ranches
# POST /ranches.json
def create
#staff = Staff.new(staff_params)
#staff.update(user_id: current_user.id)
respond_to do |format|
if #staff.save
format.html { redirect_to #staff, notice: 'Staff was successfully created.' }
format.json { render :show, status: :created, location: #staff }
else
format.html { render :new }
format.json { render json: #staff.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /ranches/1
# PATCH/PUT /ranches/1.json
def update
respond_to do |format|
if #staff.update(staff_params)
format.html { redirect_to #staff, notice: 'Staff was successfully updated.' }
format.json { render :show, status: :ok, location: #staff }
else
format.html { render :edit }
format.json { render json: #staff.errors, status: :unprocessable_entity }
end
end
end
# DELETE /ranches/1
# DELETE /ranches/1.json
def destroy
#staff.destroy
respond_to do |format|
format.html { redirect_to staffs_url, notice: 'Ranch was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_staff
#staff = Staff.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def staff_params
params.require(:staff).permit(:name, :user_id, :cat, :ranch_id)
end
end
Can you explain me why the model ranchstaff was not created after a creation of a new staff ?
As you are using fields_for you are using nested form but you are not permitting the parameters properly. First make change in your form:
<%= f.fields_for(#staff_ranch) do |x| %>
<div class="field">
<%= x.collection_select(:ranch_id, #all_ranch, :id, :name, { }, {:multiple => true}) %>
</div>
<% end %>
And then in your controller:
def staff_params
params.require(:staff).permit(:name, :user_id, :cat, ranchstaff_attributes: [ranch_id: []])
end
And in your Staff model write:
accepts_nested_attributes_for :ranchstaffs
Then your ranchstaff should be created when the User is being created.
Your ranch_id is coming in an array. So u have to specify that ranch_id would be array in strong parameters.
so your staff_params method would look like this
def staff_params
params.require(:staff).permit(:name, :user_id, :cat, :staff_ranch_attributes =>[:ranch_id => []])
end
I'm trying to implement this rails cook solution for multiple images found here and am having issues with an action controller exception. I'm sure it's something I have over looked.
Here are my .rb files:
class Picture < ActiveRecord::Base
belongs_to :gallery
has_attached_file :image,
:path => ":rails_root/public/images/:id/:filename",
:url => "/images/:id/:filename"
do_not_validate_attachment_file_type :image
end
class Gallery < ActiveRecord::Base
has_many :pictures, :dependent => :destroy
end
And my pictures controller
class PicturesController < ApplicationController
before_action :set_picture, only: [:show, :edit, :update, :destroy]
# GET /pictures
# GET /pictures.json
def index
#pictures = Picture.all
end
# GET /pictures/1
# GET /pictures/1.json
def show
end
# GET /pictures/new
def new
#picture = Picture.new
end
# GET /pictures/1/edit
def edit
end
# POST /pictures
# POST /pictures.json
def create
#picture = Picture.new(picture_params)
#document = Document.new(:name) # :name is a symbol, not
respond_to do |format|
if #picture.save
format.html { redirect_to #picture, notice: 'Picture was successfully created.' }
format.json { render :show, status: :created, location: #picture }
else
format.html { render :new }
format.json { render json: #picture.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /pictures/1
# PATCH/PUT /pictures/1.json
def update
respond_to do |format|
if #picture.update(picture_params)
format.html { redirect_to #picture, notice: 'Picture was successfully updated.' }
format.json { render :show, status: :ok, location: #picture }
else
format.html { render :edit }
format.json { render json: #picture.errors, status: :unprocessable_entity }
end
end
end
# DELETE /pictures/1
# DELETE /pictures/1.json
def destroy
#picture.destroy
respond_to do |format|
format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_picture
#picture = Picture.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def picture_params
params[:picture]
end
end
And here is my form
<!-- app/views/galleries/_form.html.erb -->
<%= form_for #gallery, :html => { :class => 'form-horizontal', multipart: true } do |f| %>
<div class="control-group">
<%= f.label :name, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :name, :class => 'text_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :description, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :description, :class => 'text_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :pictures, :class => 'control-label' %>
<div class="controls">
<!-- The magic is coming ...look at my eyes....shazammmm -->
<!-- Use HTML5 multiple attribute to enable multiple selection
and pass back to controller all files as an array, ready
for paperclip!!
file_field_tag, since images is not a gallery attribute
-->
<%= file_field_tag "images[]", type: :file, multiple: true %>
</div>
</div>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
galleries_path, :class => 'btn btn-mini' %>
</div>
<% end %>
And here is my gallery controller
class GalleriesController < ApplicationController
before_action :set_gallery, only: [:show, :edit, :update, :destroy]
# GET /galleries
# GET /galleries.json
def index
#galleries = Gallery.all
end
# GET /galleries/1
# GET /galleries/1.json
def show
end
# GET /galleries/new
def new
#gallery = Gallery.new
end
# GET /galleries/1/edit
def edit
end
# POST /galleries
# POST /galleries.json
def create
#gallery = Gallery.new(gallery_params)
respond_to do |format|
if #gallery.save
if params[:images]
#===== The magic is here ;)
params[:images].each { |image|
#gallery.pictures.create(image: image)
}
end
format.html { redirect_to #gallery, notice: 'Gallery was successfully created.' }
format.json { render json: #gallery, status: :created, location: #gallery }
else
format.html { render action: "new" }
format.json { render json: #gallery.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /galleries/1
# PATCH/PUT /galleries/1.json
def update
respond_to do |format|
if #gallery.update(gallery_params)
format.html { redirect_to #gallery, notice: 'Gallery was successfully updated.' }
format.json { render :show, status: :ok, location: #gallery }
else
format.html { render :edit }
format.json { render json: #gallery.errors, status: :unprocessable_entity }
end
end
end
# DELETE /galleries/1
# DELETE /galleries/1.json
def destroy
#gallery.destroy
respond_to do |format|
format.html { redirect_to galleries_url, notice: 'Gallery was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_gallery
#gallery = Gallery.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def gallery_params
params.require(:gallery).permit(:gallery_id, :picture)
end
end
And here is my error
Your picture_params method may be causing the problem. Try modifying it to use the following format:
def picture_params
params.require(:picture).permit(:whitelisted, :attributes, :placed, :here)
end
You can use this repo provided in the tutorial you're following as a reference.
An additional reference on strong parameters.
Hope it helps!
I want to creat a classified ads website for a project in school and I try to create a form to send a message by email at a member of the website. The email adress is contained in a model which is name "Membre" and this model is link at a model who is name "Annonce" which contained the ad.
But when I try to create that, I have this error :
param is missing or the value is empty: annonce
app/controllers/annonces_controller.rb:104:in `annonce_params'
app/controllers/annonces_controller.rb:29:in `create'
Here the Ad controller :
class AnnoncesController < ApplicationController
before_action :set_annonce, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!, :except => [:index]
# GET /annonces
# GET /annonces.json
def index
#annonces = Annonce.all
end
# GET /annonces/1
# GET /annonces/1.json
def show
end
# GET /annonces/new
def new
#annonce = Annonce.new
end
# GET /annonces/1/edit
def edit
end
# POST /annonces
# POST /annonces.json
def create
#annonce = Annonce.new(annonce_params)
#annonce.membre_id = current_membre.id
respond_to do |format|
if #annonce.save
format.html { redirect_to #annonce, notice: t('annonce_cree_succes') }
format.json { render :show, status: :created, location: #annonce }
else
format.html { render :new }
format.json { render json: #annonce.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /annonces/1
# PATCH/PUT /annonces/1.json
def update
respond_to do |format|
if #annonce.update(annonce_params)
format.html { redirect_to #annonce, notice: t('annonce_cree_succes') }
format.json { render :show, status: :ok, location: #annonce }
else
format.html { render :edit }
format.json { render json: #annonce.errors, status: :unprocessable_entity }
end
end
end
# DELETE /annonces/1
# DELETE /annonces/1.json
def destroy
#annonce.destroy
respond_to do |format|
format.html { redirect_to annonces_url, notice: t('annonce_destroy_succes') }
format.json { head :no_content }
end
end
# GET /annonces/contact/1
def contact
#form_contact = FormContact.new
if #form_contact.valid?
#MembreMailer.email_contact(Membre.where(:id => #annonce.membre_id ),current_membre,#annonce,#message)
#annonce = Annonce.find(params[:id])
#recepteur = Membre.where(:id => #annonce.membre_id )
#membre = current_membre
mail(:to => "#{recepteur.pseudo} <#{recepteur.email}>", subject: 'Reponse à l\'une de vos annnonces')
redirect_to root
end
end
# GET /annonces/report/1
def report
#annonce = Annonce.find(params[:id])
end
private
def authenticate_user!
if membre_signed_in?
#super
else
redirect_to login_path, :notice => 'Merci de vous connecter pour effecter cette action'
## if you want render 404 page
## render :file => File.join(Rails.root, 'public/404'), :formats => [:html], :status => 404, :layout => false
end
end
# Use callbacks to share common setup or constraints between actions.
def set_annonce
#annonce = Annonce.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def annonce_params
params.require(:annonce).permit(:id, :titre, :corps, :prix, :membre_id, :categorie, :created_at, :image)
end
Here the view contact :
<div class="col-md-offset-2 col-md-8 well panel panel-default">
<h2 class='panel-heading text-center'><%= t('contacter') %></h2>
<div class="panel-body text-center">
<%= form_for(:form_contact, :url => {:action => :create}) do |f| %>
<div class="field block-center">
<%= f.label "message" %></br>
<%= f.text_area(:message, size: "50x15")%>
</div></br>
<div class="actions form-group col-md-offset-3 col-md-6">
<%= submit_tag t('envoyer'), :class => "btn btn-large btn-block btn-primary" %>
</div>
<% end %>
</div>
</div>
<p class='row'> </p>
And here the FormContact class:
class FormContact < ActiveForm::Base
attr_accessor :message
validates_presence_of :message
def new
#form_contact = FormContact.new(login_form)
end
def index
#form_contact = FormContact.new
end
private
def login_form
params.require(:form_contact).permit(:message)
end
end
How can I fix that ?
Thanks in advance
This is routing error, you should call the create method of FormContactsController, not AnnoncesController create method.
<%= form_for(:form_contact, :url => {:controller => "FormContactsController", :action => :create}) do |f| %>
I am using text-editor(wysihtml5).I am having problem in saving data in database.If I have typed more than 20 lines. it shows error like " Mysql2::Error: Data too long for column 'description' at row 1".and I am using rails4.
In Model
class News < ActiveRecord::Base
attr_accessible :name,:published_on,:description
#associations
validates :name, presence: true
validates :published_on, presence: true
validates :description, presence: true
end
In Controller
class NewsController < ApplicationController
layout :setting_layout
before_action :set_news, only: [:show, :edit, :update, :destroy]
# GET /news
# GET /news.json
def index
#news = News.all
end
# GET /news/1
# GET /news/1.json
def show
end
# GET /news/new
def new
#news = News.new
end
# GET /news/1/edit
def edit
end
# POST /news
# POST /news.json
def create
#news = News.new(news_params)
respond_to do |format|
if #news.save
format.html { redirect_to #news, notice: 'News was successfully created.' }
format.json { render action: 'show', status: :created, location: #news }
else
format.html { render action: 'new' }
format.json { render json: #news.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /news/1
# PATCH/PUT /news/1.json
def update
respond_to do |format|
if #news.update(news_params)
format.html { redirect_to #news, notice: 'News was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: #news.errors, status: :unprocessable_entity }
end
end
end
# DELETE /news/1
# DELETE /news/1.json
def destroy
#news.destroy
respond_to do |format|
format.html { redirect_to news_index_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_news
#news = News.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def news_params
params.require(:news).permit(:name, :published_on, :description)
end
end
In View
<%= simple_form_for #news, html: {class: 'form-inline form-horizontal'}, :validate => true do |f|%>
<p><font color="red">Fields with * are required.</font></p>
<div class="inputs">
<%= f.input :name %>
<%= f.input :published_on, as: 'string', input_html: {class: 'datepicker'} %>
<%= f.input :description, as: 'text', :input_html =>{:rows => '100', :cols => '100', :class => 'input wysihtml5' }%>
</div>
<div class="form-actions">
<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
<i class="icon-ok icon-white"></i> Save
<% end %>
</div>
<% end %>
In Js file
$(document).ready(function(){
$(".wysihtml5").wysihtml5();
})
In view I have given row and cols value. But it takes only cols value.
You have probably set it as a string in your migration file, rather than text.
string fields are interpreted as varchar, and are limited in character length. text fields are not.
if the field is text, change it to longtext e.g.
change_column :your_table, :your_column, :longtext