Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #_form.html.erb
- <%= form_for([@user , @user.newss.build]) do |form| %>
- <%# if news.errors.any? %>
- <div id="error_explanation">
- <h2><%#= pluralize(news.errors.count, "error") %> prohibited this
- news from being saved:</h2>
- <ul>
- <%# news.errors.full_messages.each do |message| %>
- <li><%#= message %></li>
- <%# end %>
- </ul>
- </div>
- <%# end %>
- <div class="field">
- <%= form.label :title %>
- <%= form.text_field :title %>
- </div>
- <div class="field">
- <%= form.label :description %>
- <%= form.text_area :description %>
- </div>
- <div class="actions">
- <%= form.submit %>
- </div>
- <% end %>
- #my user.rb
- class User < ApplicationRecord
- # Include default devise modules. Others available are:
- # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :validatable
- has_many :news
- end
- #my news.rb
- class News < ApplicationRecord
- has_many :comments
- belongs_to :user
- end
- ##it shows different kind of errors I can't understand that...##
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement