المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : مشكلة في الـــAdd comment ( اتمنى احد يحلها لي )



admin
11-01-2013, بتوقيت غرينيتش 02:01 PM
http://www.dzbatna.com/images/icons/questionmark.gif ظ…ط´ظƒظ„ط© ظپظٹ ط§ظ„ظ€ظ€ظ€Add comment ( ط§طھظ…ظ†ظ‰ ط§ط*ط¯ ظٹط*ظ„ظ‡ط§ ظ„ظٹ ) (http://www.dzbatna.com/t1096594/)



السلام عليكم ورحمة الله وبركاته


عندي مشكلة في الــAdd comment ( اضافة تعليق ) في موقع اخباري في ربطها في الداتا بيز database









طبعا الموقع مصمم بأستخدام InstantRails , Ruby , html and database




هذا الكود code


In Controller

رمز Code:
class CommentController < ApplicationController def list @comments = Comment.find(:all) end def new @comment = Comment.new end def create @comment = Comment.new(params[:comment]) @comment.Date = Date.today if @comment.save redirect_to :action => 'list' else render :action => 'new' end end def delete @id = params[:CommentID] Comment.delete(@id) redirect_to :action => 'list' end end

In View (list.rhtml):

رمز Code:
<html> <head> </head> <body> <% if @comments.blank? %> <p>There are not any comments currently in the system.</p> <% else %> <p>These are the current comments in our system</p> <ul id=&quot;comments&quot;> <% @comments.each do |c| %> <li><%= link_to c.CommentBody, {:action => 'show', :CommentBody => c.ID} %> <b> <%= link_to &quot;Delete&quot;, {:action => 'delete', :CommentID => c.ID}, :confirm => &quot;Are you sure you want to delete this Comment?&quot; %></b> </li> <% end %> </ul> <% end %> <p><%= link_to &quot;Add new Comments&quot;, {:action => 'new' }%></p> </body> </html>

In View (new.rhtm):

رمز Code:
<html> <head> </head> <body> <h1>Add new Comment</h1> <% form_tag :action => 'create' do %> <p><label for=&quot;Comment_Body&quot;>Your Comment :)</label><br/> <%= text_area 'comment', 'CommentBody' %></p> <%= submit_tag &quot;submit&quot; %> <% end %> <%= link_to &quot;Back&quot;, {:action => 'list'} %> </body> </html>
and this is the DataBase for Comment table:


رمز Code:
Table structure for table `comments` -- CREATE TABLE `comments` ( `NewsID` int(15) NOT NULL, `ID` int(15) NOT NULL auto_increment, `CommentBody` varchar(10000) NOT NULL, `Date` varchar(15) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; -- -- Dumping data for table `comments` --

http://www.dzbatna.com/images/smilies/tears.gif

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى