Reputation: 155
I'm creating a Blog app with RoR using MaterializeCss for my Styling, already created this:
class Post < ApplicationRecord
belongs_to :user
belongs_to :category
has_many :comments, dependent: :destroy
validates :title, presence: true, length: { minimum: 5 }
validates :body, presence: true
end
Also this:
class Category < ApplicationRecord
belongs_to :user
has_many :posts
validates :name, presence: true, length: { minimum: 3 }
end
Also added the migration:
class AddCategoryToPost < ActiveRecord::Migration[5.0]
def change
add_reference :posts, :category, foreign_key: true
end
end
Update: I have this form_for:
<%= form_for @post do |f| %>
<% if @post.errors.any? %>
<ul class="collection with-header">
<li class="collection-header"><h5><%= pluralize(@post.errors.count, "error") %> prevented this post from saving</h5></li>
<% @post.errors.full_messages.each do |msg| %>
<li class="collection-item"><%= msg %></li>
<% end %>
</ul>
<% end %>
<div class="input-field">
<%= f.label :title %><br>
<%= f.text_field :title%>
</div>
<div class="input-field">
<%= f.label :body %><br><br>
<%= f.hidden_field :body, class: "materialize-textarea", id: :post_body %>
<trix-editor input="post_body"></trix-editor>
</div>
<div class="input-field">
<%= f.label :category_id %>
<%= f.collection_select(:category_id, Category.all, :id, :name) %>
</div>
<br> <br> <br> <br>
<div class="right">
<%= f.submit "Save Post", class: "waves-effect waves-light btn" %>
</div>
<% end %>
And as you can see I'm trying to list all my Categories from Category Model, but in my browser I have this result:
As you can see, it render all the Categories(javascript, ruby on rails, angularjs, PHP) but I can't see the Select in my New Post Form and Can't click on the Select,
any clue?
Update: Removed Materializecss classes, and Still Not Showing the Select Input
Upvotes: 0
Views: 852
Reputation:
I had the same problem too. What I did id just in my Css I added
select{
display: block;
}
And that fixed the issue
Upvotes: 2
Reputation: 155
Found the problem, it's MaterializeCss that is Not showing me the Select Input, and I don't now Why?. Going back to my old friend Bootstrap
Upvotes: -1