Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ActiveRecord::RecordNotFound in AlbumsController#create
- Couldn't find User without an ID
- <%= form_for (@album), :remote => true, :html => { :id => "uploadform", :multipart => true } do |f| %>
- <div>
- <%= f.label :name %>
- <%= f.text_field :name %>
- <%= f.label :description %>
- <%= f.text_area :description %>
- <%= f.fields_for :avatar do |avatar_form| %>
- <%= avatar_form.label :avatar, "Upload" %>
- <%= avatar_form.file_field :avatar, :multiple => true %>
- <% end %>
- <%=f.submit %>
- </div>
- <% end %>
- def create
- @users = User.all
- @user = User.find(params[:user_id])
- @album = @user.albums.build(params[:album])
- if @album.save
- flash[:success] = "Album created!"
- end
- end
- Pholder::Application.routes.draw do
- resources :users do
- resources :albums
- end
- resources :albums do
- resources :pictures
- end
- class Album < ActiveRecord::Base
- attr_accessible :avatar, :name, :description
- has_and_belongs_to_many :users
- has_attached_file :avatar
- end
- def create
- @users = User.all
- @album = Album.new(params[:album].merge!(:user_id => current_user))
- if @album.save
- flash[:success] = "Album created!"
- end
- end
- def create
- @users = User.all
- @album = Album.new(params[:album])
- @album.user_id = current_user.id
- if @album.save
- flash[:success] = "Album created!"
- end
- end
Add Comment
Please, Sign In to add comment