Ruby on Rails - Partial view instance variable scope

I do not understand how to use the instance variable with partial views correctly; I hope that someone here can enlighten me. For example:

class MainController < ApplicationController

  def index
    @item_list = Item.find_all_item
  end

  def detail_display
    @current_selected = @item= Item.find(params[:id])
      redirect_to :action => :index
  end
end

detail_displayCalled when a user clicks on an item in a list. A variable that is @current_selectednot viewable is called when the index is redirected. How can i fix this?

thanks

+3
source share
1 answer

, . , , ; , .

- ? - , , . , , Ajax. , , index index.

+8

Source: https://habr.com/ru/post/1704038/


All Articles