Search Results

Search found 5 results on 1 pages for 'thermans'.

Page 1/1 | 1 

  • Help me understand dynamic layouts in Sinatra

    - by thermans
    Help me understand this; I'm learning Sinatra (and Rails for that matter, er, and Ruby). Say I'm doing a search app. The search form is laid out in one div, and the results will be laid out in another. The search form is rendered into the div by a previous view (maybe from a login form). I want to process the form params, perform the search, and render the results into the results div. If I have a single "yield" in the layout and render the divs from different views, the results div erases the search div when it renders. If I define the divs in the default layout, then just render the content, obviously the layout will be messed up: there would have to be two "yields" and I don't think Sinatra supports passing blocks in to yields. I tried foca's sinatra-content-for plugin, and that seems closer to what I need. But I can't figure out where to place the "yield_content" statements. If I have this haml in my layout: #search -# search form = yield_content :search #results -# search results = yield_content :results ... this in my search view: - content_for :search do %form{:method => "post"... etc. ... and this in the results view: - content_for :results do %table{:class => 'results'... etc. This sort of works but when I render the results view, the search div is emptied out. I would like to have it remain. Am I doing something wrong? How should I set this up?

    Read the article

  • Execute ruby code in a link in Haml

    - by thermans
    I want to have a "delete user" link in a normal Activerecord table, but I can't figure out how to wrangle the inline ruby in haml. I have this: %tbody - @users.each do |user| %tr %td= user.name %td= user.login %td %a %img{:src => '../images/delete.png', :title => 'Delete user'} How do I make the - user.destroy be a clickable link in Haml?

    Read the article

  • Rails routing: how to mix "GET" and "PUT"

    - by thermans
    Not sure how to frame this question (I'm still wrapping my head around Rails). Let's try this: Say I wanted to implement the user side of Ryan Bates' excellent railscast on nested models. (He shows how to implement a survey where you can add and remove questions and answers dynamically). I want the user's side of this: to be able to answer questions and, not in the tutorial, be able to add comments. It seems to me that you have to implement a view that shows the questions and answers, allow selection of the answers, and the input of comments. So there would need to be a way to show the information, but also update the model on input, right? I know I'm not explaining this very well. I hope you understand what I'm getting at. Is it just a question of setting up the right routes? Or is there some controller mojo that needs to happen?

    Read the article

1