SHARE
TWEET

Untitled

a guest Jul 12th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #_form.html.erb
  2. <%= form_for([@user , @user.newss.build]) do |form| %>
  3.   <%# if news.errors.any? %>
  4.     <div id="error_explanation">
  5.       <h2><%#= pluralize(news.errors.count, "error") %> prohibited this
  6. news from being saved:</h2>
  7.  
  8.       <ul>
  9.       <%# news.errors.full_messages.each do |message| %>
  10.         <li><%#= message %></li>
  11.       <%# end %>
  12.       </ul>
  13.     </div>
  14.    <%# end %>
  15.  
  16.   <div class="field">
  17.     <%= form.label :title %>
  18.     <%= form.text_field :title %>
  19.   </div>
  20.  
  21.   <div class="field">
  22.     <%= form.label :description %>
  23.     <%= form.text_area :description %>
  24.   </div>
  25.  
  26.   <div class="actions">
  27.     <%= form.submit %>
  28.   </div>
  29. <% end %>
  30.  
  31. #my user.rb
  32. class User < ApplicationRecord
  33.   # Include default devise modules. Others available are:
  34.   # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  35.   devise :database_authenticatable, :registerable,
  36.          :recoverable, :rememberable, :validatable
  37.   has_many :news
  38. end
  39. #my news.rb
  40. class News < ApplicationRecord
  41.     has_many :comments
  42.     belongs_to :user
  43. end
  44.  
  45.  
  46. ##it shows different kind of errors I can't understand that...##
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top