search for: commentscontrol

Displaying 20 results from an estimated 22 matches for "commentscontrol".

2011 Aug 04
1
Creating form for associated has_many model
...here ''Comment'' belongs_to ''Post'' and ''Post has_many ''Comments''. http://edgeguides.rubyonrails.org/getting_started.html#generating-a-controller How might I modify that to display all the comments in the form, and still have it call the CommentsController (versus having the form call the PostsController, as in the example here http://railscasts.com/episodes/17-habtm-checkboxes)? Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonr...
2008 Mar 16
3
undefined method `redirect_to'
Hi all. I''m getting the following error in my app: undefined method `redirect_to'' for ActionController::Base:Class I''m using Windows 2000, Rails 2.0.2 and resource_controller (from James Golick). My controller: class CommentsController < ApplicationController include ResourceController::Controller belongs_to :post, :article, :photo create do ActionController::Base.redirect_to :back end end I''ve been also trying to use the following: class CommentsController < ResourceController::Base bel...
2009 Aug 16
5
any help with captcha in my comments ?
...+ZrEs1S0KkYsmK8VMzCOeDEf731w21zY=", "captcha"=>"asdasd", "_"=>""} SyntaxError (/Users/webstic/Sites/weblog/app/controllers/comments_controller.rb:11: syntax error, unexpected kELSE, expecting kEND else ^): this is my code: class CommentsController < ApplicationController include SimpleCaptcha::ControllerHelpers def create if simple_captcha_valid? @post = Post.find(params[:post_id]) @comment = @post.comments.create!(params[:comment]) respond_to do |format| format.html { redirect_to @post } format.js...
2009 Feb 20
6
How to mock an object defined in the before_filter function?
...@comment.id #to be used in rendering partial @comment.destroy respond_to do |format| format.js end end def find_comment @comment = Comment.find(:first, :conditions => [''id= ?'',params [:comment_id]]) end ===============spec_file spec code describe CommentsController, "while deleting a comment" do it "should render destroy.rjs in case of success" do @comment = mock_model(Comment) @comment.stub!(:id).and_return(1) @comment.stub!(:destroy).and_return(:true) controller.stub!(:find_comment).and_return(@comment) # execu...
2007 Mar 24
1
spec''ing metaprograming & rails CRUD
...lt; self private def model # get a default name based on the controller name # or specify a name end def belongs_to # the model''s "belongs_to"/foreign key relationship # this could also be found dynamically end end end class CommentsController < CrudController model :comments belongs_to :post end And then this would generate the typical nested crud, with before_filter and all of that jazz Anyway, here goes my question. The CrudController''s specs should set a bunch of instance variables (such as @comments = @po...
2010 Sep 01
5
validation errors bring up stack trace error page
...m_for [@post, Comment.new] do |f| %> <p> <%= f.label :title, "Your Comment" %><br /> <%= f.error_messages %> <%= f.text_field :title %><br /> </p> <%= f.submit "Submit Your Comment" %> controller code: class CommentsController < ApplicationController def create @post = Post.find(params[:post_id]) @comment = @post.comments.create!(params[:comment]) redirect_to @post end end Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Googl...
2009 Feb 21
1
undefined method user_id
Basically, Im trying to add comments to photos that other users have uploaded. And Ive encountered an error: NoMethodError in CommentsController#create undefined method `user_id='' for #<Comment:0x4768cd0> C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1857:in `method_missing'' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1672:in `send&...
2007 May 29
12
questions rspec on rails
Hi, rather than flooding this list with separate emails, I''ve been queueing up questions using rspec with rails. (an irc channel would be nice too :) Here ya go... - Is there a way to test named routes? - Could I get an example how to test an ajax request (link_to_remote)? would that go in view? and/or in controller spec? - Can you assert which layout template is rendered in a
2009 Aug 02
2
Multiple app directories
Hi, I''m wondering if there is possibility to make multiple ''apps'' under one Rails Application. That is multiple app directories but sharing the same server, the same configuration, etc. One might be ''admin'' and the other — ''user''.. Some directories (models) might be shared via symlink. The reason is that I don''t want to have
2008 Jan 23
11
Rails 2.0.2 + RJS
...create.js page.insert_html :bottom, ''comments'', :partial => ''comment'' page.visual_effect :appear, "comment_#{@comment.id}" page.visual_effect :highlight, "comment_#{@comment.id}", {:startcolor => ''"#84E003"''} commentscontroller.rb: def create @comment = Comment.new(params[:comment]) @comment.user = User.find(current_user) @comment.story = Story.find(params[:story_id]) respond_to do |format| if @comment.save format.html { redirect_to story_url(@comment.story) } format.js else format...
2006 Dec 10
5
model-controller-paradigm: What about admin controllers?
Hi all We all know the model-controller-paradigm: I have a model "News" which has a corresponding CRUD-controller "NewsController". But now I''m quite unsure about the following... Guess we have normal visitors that visit our site www.??.com/news and we have administrators that create and modify news items. The admin should see an "Edit" link and a
2007 Mar 24
0
Using spec fixtures with integration tests
...ult name based on the controller name > # or specify a name > end > > def belongs_to > # the model''s "belongs_to"/foreign key relationship > # this could also be found dynamically > end > end > end > > class CommentsController < CrudController > model :comments > belongs_to :post > end > > And then this would generate the typical nested crud, with > before_filter and all of that jazz > > Anyway, here goes my question. The CrudController''s specs should set > a bunch o...
2006 Mar 05
1
access methods defined in helper
Hey How do I access methods that I have defined in helpers? __________________________________________ Helper id_browser_helper.rb: module IdBrowserHelper def table_identities(message) render_text message end end ___________________________________________ Controller id_browser_controller.rb: class IdBrowserController < ApplicationController def view_genre()
2006 Nov 22
1
Peepcode REST podcast. ..didn't anybody get it ?
And if so, I''m going a bit bonkers here and need to watch it again, but if I remember correctly, scaffold_resource generator was used, but for nested resources the show and index were removed from the controller ? Is this correct as far as what happened in the demonstration and if so is it correct as far as rest goes ? TIA Stuart -- http://en.wikipedia.org/wiki/Dark_ambient
2007 Aug 23
1
validation across controllers
...end ... end ------------------------------------------------------------------------------------------------------------------------------------- and ------------------------------------------------------------------------------------------------------------------------------------- class CommentsController < ApplicationController ... def create @comment = Post.find(params[:post_id]).comments.new(params[:comment]) @comment.user = current_user if @comment.save redirect_to post_path(@comment.post) else # ?? end end ... end --------------------------------...
2011 Jan 25
0
Rails 3 - Helping with a Commenting Module
class CommentsController < ApplicationController def create @commentable= context_object() @comment = @commentable.comments.build(params[:comment].merge(:user_id => current_user.id)) if @comment.save respond_to do |format| format.js end...
2006 Aug 05
0
Another generic CRUD controller
I''ve been using this template on most of my CRUD controllers. class CommentsController < ApplicationController meantime_filter :set_scope before_filter :find_comment, :only => %w(show edit update destroy) def index @comments = Comment.find(:all) end def new @Comment = Comment.new end def create @comment = Comment.create!(params[:comment]) red...
2010 Oct 14
7
undefined method?
I''m trying to learn rails as I go along, and having a bit of trouble. There is an undefined method cropping that I don''t know why rails thinks should be there. Firstly, I''m using rails 3, ruby 1.9.2 I have a controller with an index action This part works fine, but i am trying to add a comment form to the page that is rendered by that index action. Supposing my
2006 Jan 12
16
master detail problem
Hello all, Has anyone done one of these? I''ve done similar things in java and php, by having easy access to SQL statements. I am new to Ruby/Rails( I''ve been at it for 10 days ) and thus far find it extremely confusing. I''ve got a bit more of a handle on it from the Agile book that someone loaned me, but I still find it hard to understand. Anyway, I''ve got
2011 Apr 18
2
acts_as_commentable validations
Hi all, I recently started back up with Rails and things are going well up until now. I''ve set up acts_as_commentable in my Post model and it''s working great. Problem is users are able to create a "blank" comment. I''ve added the following validations in the comment.rb file generated by acts_as_commentable to limit the comment length: [code]