ruby on rails - undefined method `index_path' using relation -
i next error using device , carrierwave gem:
undefined method `user_media_index_path' .showing .../user_medias/new.html.erb line #3 raised:
i have added index on user_id in user_media model
i have implemented file upload for single model don't know how seperate module.
new.html
form_for @media, :html =>{:multipart =>true} |f| upload image f.file_field :image f.submit end
this user model generated using device gem:
user.rb
class user < activerecord::base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :email, :password, :password_confirmation, :remember_me has_many :user_media, dependent: :destroy end
its model store user medias images,etc i;m using images future add together more types of media have created user_media model
user_media.rb
class usermedia < activerecord::base attr_accessible :anudio, :image, :video belongs_to :user mount_uploader :image, mediauploader end
this redirected when asked create action uploading image
user_medias_controller
class usermediascontroller < applicationcontroller def new @media = usermedia.new end def create @media=current_user.user_media.build(params[:media]) if @media.save render'index' else render'new' end end end
the routing details are:
routes.rb
projectx::application.routes.draw "dashboard/index" resources :dashboard, :usermedias "home/index" devise_for :users root :to => 'home#index' match 'uploder' =>'usermedias#new'
rake routes output after adding resources suggested @peter
dashboard_index /dashboard/index(.:format) dashboard#index /dashboard(.:format) dashboard#index post /dashboard(.:format) dashboard#create new_dashboard /dashboard/new(.:format) dashboard#new edit_dashboard /dashboard/:id/edit(.:format) dashboard#edit dashboard /dashboard/:id(.:format) dashboard#show set /dashboard/:id(.:format) dashboard#update delete /dashboard/:id(.:format) dashboard#destroy user_medias /user_medias(.:format) user_medias#index post /user_medias(.:format) user_medias#create new_user_media /user_medias/new(.:format) user_medias#new edit_user_media /user_medias/:id/edit(.:format) user_medias#edit user_media /user_medias/:id(.:format) user_medias#show set /user_medias/:id(.:format) user_medias#update delete /user_medias/:id(.:format) user_medias#destroy home_index /home/index(.:format) home#index new_user_session /users/sign_in(.:format) devise/sessions#new user_session post /users/sign_in(.:format) devise/sessions#create destroy_user_session delete /users/sign_out(.:format) devise/sessions#destroy user_password post /users/password(.:format) devise/passwords#create new_user_password /users/password/new(.:format) devise/passwords#new edit_user_password /users/password/edit(.:format) devise/passwords#edit set /users/password(.:format) devise/passwords#update cancel_user_registration /users/cancel(.:format) devise/registrations#cancel user_registration post /users(.:format) devise/registrations#create new_user_registration /users/sign_up(.:format) devise/registrations#new edit_user_registration /users/edit(.:format) devise/registrations#edit set /users(.:format) devise/registrations#update delete /users(.:format) devise/registrations#destroy root / home#index uploder /uploder(.:format) user_medias#new
the error points missing route in routes file. add together routes
resources :user_medias
ruby-on-rails
No comments:
Post a Comment