This may be more help than you were after... I often customize the
front index page.  Here is a copy of a current project and a lot has
been stripped out for this example, nothing is tested so try and
understand it rather than cut and paste.

The technique is to define the guts of the page in application.dryml
so it can be called from a partial update. Dry you know :)

It probably doesn't work exactly as you see it here because of the
quick edits I have made to it but it should give some ideas of how you
could go about things.


front/index.dryml

<page>

  <body: class="front-page" />

  <ajax_progress:/>

  <content:>

    <header class="content-header">
      <h1 if="&current_user.guest?">Welcome to <app-name/></h1>
      <section class="welcome-message" if="&current_user.guest?">
        <h3>What this app is about</h3>
        <ul>
          <li>A little blurb here.</li>
        </ul>
      </section>
    </header>

        <users-posts/>

  </content:>

</page>




added to application.dryml


<def tag="users-posts">

  <section part="usersposts" if="&(not current_user.guest?)">

      <table-plus if="&(not @users_posts.nil?)" with="&@users_posts"
fields="this,comments,date,etc">
        <header: replace/>

                <Usersposts-heading:>Users Posts</Usersposts-heading:>

        <controls:>

          <%= link_to_remote( "select",
              :update => "usersposts",
              :loading  => "Hobo.showSpinner('Selecting...');",
              :complete => "Hobo.hideSpinner();",
              :message => "Saving...",
              :url => { :action => :add_new, :id => this.id } )
          %>


        </controls:>

        <empty-message:>
          No posts
        </empty-message:>
      </table-plus>


  </section>

</def>


added to front_controller.rb

  def index

    # find out what params are showing up

    logger.info "front_controller.rb index CALLED===params=" +
params.to_s

    @user = current_user
    if not current_user.guest?
      @users_posts       = @user.posts if params["sort"].nil?
    end

  end



  def add_new

    mp = posts.find(:all,:conditions =>  "user_id=" +
current_user.id.to_s + " and post_id=" + params["id"].to_s)
    success = false
    mp.each do |x|
      x.status = "selected"
      x.save
      success = true
    end

    if success
      @user = current_user
      @users_posts = @user.posts
      render :partial => "users_posts", :object =>
[...@users_posts,@user]
    else
      render :text => "Something weird happened"
    end
  end


And then of course a partial _users_posts.dryml

<%
  @users_posts = users_posts[0]
  @users = users_posts[1]
%>

       <users-posts/>





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to