ruby - Rails Link_to is linking to undesired view -


my link_to in view going different "show.html.erb" i'd to. i'm trying understand why "link_to @exhibit linking "investigation" profile. think may have routes file or fact "belong to" relationship...but can't seem workin...what should link_to be?

update: (as per brois question) missing misbehaving link_to in <%= link_to @exhibit %> in show.html.erb

my exhibit.rb (model)

class exhibit < activerecord::base   attr_accessible :content, :investigation_id, :name, :user_id, :media, :media_html   belongs_to :investigation    has_many :categorizations   has_many :categories, :through => :categorizations    validates :name, presence: true, length: { maximum: 140 }   validates :content, presence: true   default_scope -> { order('created_at desc') }    auto_html_for :media   html_escape   image   youtube(:width => 400, :height => 250)   link :target => "_blank", :rel => "nofollow"   simple_format end 

my exhibit controller:

class exhibitscontroller < applicationcontroller include autohtml  def new @exhibit = exhibit.new end  def show @exhibit = exhibit.find(params[:id]) end  def index @exhibits = exhibit.paginate(page: params[:page]) end  def create   @investigation = investigation.find(params[:investigation_id])   @exhibit = @investigation.exhibits.create(params[:exhibit])   if @exhibit.save   flash[:success] = "you've added etc etc..."   redirect_to investigation_path(@investigation)   else   render 'new'   end end  end 

my routes.rb

resources :sessions, only: [:new, :create, :destroy]  resources :investigations resources :players end  resources :investigations resources :exhibits end 

lastly show.html.erb (investigation profile)

<% @investigation.exhibits.each |exhibit| %>   <div class="row-fluid services_circles">     <%= link_to @exhibit %>     <div class="media">       <div class="pull-left">         <%= exhibit.media_html %>       </div>       <div class="media-body">         <h4 class="media-heading"><%= exhibit.name %></h4>         <p><%= exhibit.content %></p>       </div>     </div>     <% end %> <% end %> 

added investigations controller

class investigationscontroller < applicationcontroller   def new   @investigation = investigation.new end  def show    @investigation = investigation.find(params[:id]) end  def index   @investigations = investigation.paginate(page: params[:page]) end  def create   @investigation = investigation.new(params[:investigation])   if @investigation.save     flash[:success] = "you've created..."     redirect_to @investigation   else     render 'new'   end end  end 

added investigation model

class investigation < activerecord::base   # belongs_to :user    has_many :players, dependent: :destroy   has_many :exhibits, dependent: :destroy     default_scope -> { order('created_at desc') } end 

i appreciate help...if need post more info let me know

in : app/contorollers/exhibits_controller.rb

def show @investigation = investigation.find(params[:investigation_id]) @exhibit = exhibit.find(params[:id]) end 

in : app/views/exhibits/show.html.erb

<%= link_to investigation_exhibit_path(@investigation, @exhibit) %> 

maybe, think.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -