Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 6th, 2012, 02:07 PM
drumlegend drumlegend is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 8 drumlegend User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 54 m 52 sec
Reputation Power: 0
Posting comments to database via a form

So I am trying to submit a comment to an form that will display on the page. I want to be able to do this in ajax or prototype.

This is the html for the form.

Code:
<p id="notice"><%= notice %></p>

<p>
  <b>Title:</b>
  <%= @image.title %>
</p>

<p>
  <%= image_tag @image.filename %>
</p>

<p>
  <b>Likes:</b>
  <span id="image_<%=@image.id%>_likes_count"><%= @image.likes %></span>
</p>

<form>
        <label>Name:</label>
            <input type="text" name="name" />
        <label>Comment:</label>
            <input type="text" name="comment"  />
            <input type="submit" value="Submit" name="submit" class="post" />
</form>


<div id="comments">

  <h2>Comments displayed here</h2>

<%= render :partial => "shared/comment", :collection => @image.comments%>

</div
 

<%= link_to 'Like', like_image_path(@image), :method => :post %> |
<%= link_to 'Edit', edit_image_path(@image) %> |
<%= link_to 'Back', images_path %>


This is the db for create_commentables

Code:
class CreateCommentables < ActiveRecord::Migration
  def self.up
    create_table :commentables do |t|
      t.integer :commentator_id
      t.integer :resource_id
      t.string :resource_type
      t.integer :commentator_id
      t.string :commentator_type
      t.text :comment

      t.timestamps
    end
  end

  def self.down
    drop_table :commentables
  end
end

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Posting comments to database via a form

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap