0

i got a simple rails app for browser bookmarks.
image here
a bookmark, seen on the top, is a folder that contains the subcategory folders in the left sidebar.
when clicking a folder on the left one gets the bookmarks listing of the folder. i.e. a bookmarks#index with params. same is folder#index with params on the left and top. how can i render all the 3 controller action on one page?

2
  • You can use partials. Checkout guides.rubyonrails.org/… Commented May 25, 2018 at 11:05
  • @user9675688 checkout the given answer below, i believe it will be helpful for you, let me know for further guidance. Commented May 25, 2018 at 11:16

2 Answers 2

0

Well you can definitely render to a common page from different actions, see the example:- in bookmarks_controller.rb

def index
  #do your stuffs
  render "path_of_comman_page",locals: {x: "foo", y: "bar"}
end

in folder_controller.rb

def index
  #do your stuffs
  render "path_of_comman_page",locals: {x: "foo", y: "bar"}
end

So here by you will be able to access all locals variable at your comman page. like x, y path_of_comman_page can be for example /bookmarks/listings which means you are rendering data to bookmarks controller listings.html.erb

Alternative it can be done by common partial for example

def index
  #do your stuffs...
  respond_to do |format|
    format.html { render partial: "listings/listing", locals: {x: "foo", y: "bar"}}
  end
end
Sign up to request clarification or add additional context in comments.

Comments

0

actually i want it like this, somehow with js. maybe it's possible with a controller too ... folders/index.haml

.container_top
- @folders.each do |f|
  - if f.is_rootparent?
    -# send ajax to fetch subcategory folders!
    =link_to folder_path(parent: f), remote: true do
      .bookmark_vertical
        %p = f.title
.container_left
  #appendsubcategoryfoldershere

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.