Hello i'm newbie in Ruby on Rails i've got following error
No route matches {:action=>"show", :controller=>"collections"} missing required keys: [:id]
I think problem is occuring in routes and here is my code
<% @collections.take(7).each do |c| %>
<div class="col-md-3">
<%= link_to c do %>
<div class="well" style="background:
linear-gradient(
rgba(1, 0, 0, 0.4),
rgba(1, 0, 0, 0.4)
),
url(<%= c.avatar.url %>);
background-size: cover;">
<h3 class="text-center"><%= c.name %></h3>
<h6 class="text-center">30 places</h6>
</div>
<% end %>
</div>
<% end %>
And here is routes.rb
resources :collections, only: [:index, :show]
root 'pages#index'
namespace :admin do
resources :places
resources :collections, only: [:new, :create]
end
UPDATE!
Here is my collection controller within Admin namespace
class Admin::CollectionsController
before_action :authenticate_user!
layout 'dashboard'
def new
@collection = Collection.new
end
def create
@collection = Collection.new(coll_params)
if @collection.save
redirect_to new_admin_collection_path
else
render 'new'
end
end
def show
end
def update
if @collection.update(coll_params)
redirect_to @collection
else
render 'edit'
end
end
def destroy
@collection.destroy
redirect_to root_path
end
private
def find_coll
@collection = Collection.find(params[:id])
end
def coll_params
params.require(:collection).permit(:name, :avatar)
end
end
Aucun commentaire:
Enregistrer un commentaire