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="comments"> <% @comments.each do |c| %> <li><%= link_to c.CommentBody, {:action => 'show', :CommentBody => c.ID} %> <b> <%= link_to "Delete", {:action => 'delete', :CommentID => c.ID}, :confirm => "Are you sure you want to delete this Comment?" %></b> </li> <% end %> </ul> <% end %> <p><%= link_to "Add new Comments", {: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="Comment_Body">Your Comment :)</label><br/> <%= text_area 'comment', 'CommentBody' %></p> <%= submit_tag "submit" %> <% end %> <%= link_to "Back", {: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
السلام عليكم ورحمة الله وبركاته
عندي مشكلة في الــ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="comments"> <% @comments.each do |c| %> <li><%= link_to c.CommentBody, {:action => 'show', :CommentBody => c.ID} %> <b> <%= link_to "Delete", {:action => 'delete', :CommentID => c.ID}, :confirm => "Are you sure you want to delete this Comment?" %></b> </li> <% end %> </ul> <% end %> <p><%= link_to "Add new Comments", {: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="Comment_Body">Your Comment :)</label><br/> <%= text_area 'comment', 'CommentBody' %></p> <%= submit_tag "submit" %> <% end %> <%= link_to "Back", {: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