Skip to content

Instantly share code, notes, and snippets.

@trekdemo
Forked from azabaj/gist:1105173
Created July 25, 2011 20:52
Show Gist options
  • Select an option

  • Save trekdemo/1105176 to your computer and use it in GitHub Desktop.

Select an option

Save trekdemo/1105176 to your computer and use it in GitHub Desktop.

Revisions

  1. trekdemo revised this gist Jul 25, 2011. 2 changed files with 14 additions and 1 deletion.
    13 changes: 13 additions & 0 deletions comments_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    helper_method :grand_parent, :parent, :resource

    def grand_parent

    end

    def parent
    @parent = params ....
    end

    def resource
    @comment = params[:id] ? parent.comments.find( params[:id] ) : parent.comments.new( params[:comment] )
    end
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # comments/_form.html.erb
    <div class="new_comment">
    <% form_for [@project, @message, @comment ] do |f| %>
    <% form_for [grand_parent, parent, resource ] do |f| %>
    <%= error_messages @comment %>
    <p><%= f.label :content, 'Szólj hozzá!' %>
    <%= f.text_area :content, :class => 'text maxwidth' %></p>
  2. trekdemo revised this gist Jul 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # comments/_form.html.erb
    <div class="new_comment">
    <%= form_for(@comment, :url => project_message_comments_path(@project,@message)) do |f| %>
    <% form_for [@project, @message, @comment ] do |f| %>
    <%= error_messages @comment %>
    <p><%= f.label :content, 'Szólj hozzá!' %>
    <%= f.text_area :content, :class => 'text maxwidth' %></p>
  3. @azabaj azabaj created this gist Jul 25, 2011.
    16 changes: 16 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # comments/_form.html.erb
    <div class="new_comment">
    <%= form_for(@comment, :url => project_message_comments_path(@project,@message)) do |f| %>
    <%= error_messages @comment %>
    <p><%= f.label :content, 'Szólj hozzá!' %>
    <%= f.text_area :content, :class => 'text maxwidth' %></p>
    <div class="submit_wrapper">
    <%= f.submit 'Elküldöm a hozzászólást' %>
    </div>
    <% end %>
    </div>
    # és ezt a paritalt vagy a messages/show-ból húzzuk be
    # vagy a statuses/show-ból. és ennek megfelelően kell majd postolni és a kontrollerben pedig redirectelni