Thursday, October 15, 2009

Ruby on Rails : Comment Single line / Multiple lines

Comment single line of code is using "#", however, for multiple line is using "=begin" and "=end" in .rb, and "<!-- -->" in .rhtml.

In Controller.rb









10 
11 
12 
13 
14 
15 
16 
17 
18 
    # Single line
    # PUT /people/1
    # PUT /people/1.xml

    def update
      @person = Person.find(params[:id])
=begin (Multiple lines)
      respond_to do |format|
       if @person.update_attributes(params[:person])
        flash[:notice] = 'Person was successfully updated.'
        format.html { redirect_to(@person) }
        format.xml { head :ok }
       else
        format.html { render :action => "edit" }
        format.xml { render :xml => @person.errors, :status => :unprocessable_entity }
       end
      end
=end

    end

In View.rhtml
<!-- Single Line -->
<% # @people = Person.find(:all) %>

<!-- Multiple Lines -->
<!--
<% for person in @people %>
<%= person.name %>
<% end %>
-->

12 comments:

  1. Thanks for sharing such a nice tip. Whenever some one is new to web development it is very important to first learn programming language as per my knowledge. Well ruby is one of the best programming language for Rails development. If you are looking for ROR developers in India email us at: info@cryptextechnologies.com

    ReplyDelete
    Replies
    1. When you are searching to hire a website design company then you should always choose reliable and professional, Revise is the best government website design company which contains good record and be ready to give you site according to your needs.

      Delete
  2. Thanks for the tips on the comment single line in ROR. You can find related web development tools and resources here. http://www.jqueryplugins.net

    ReplyDelete
  3. Great article Lot's of information to Read... Great Man Keep Posting and update to People..Thanks

    java forums

    ReplyDelete
  4. perfect explanation about java programming .its very useful.thanks for your valuable information.java training in chennai | java training in chennai chennai, tamil nadu

    ReplyDelete
  5. Great, what a collaboration. I love your blog post. keep sharing. Thanks
    Hire RoR Developer

    ReplyDelete
  6. Great sharing. Cryptex Technologies Pvt. Ltd. is an IT company which focuses on providing services to client. The company works on Ruby on Rails Platform since it was started in October 2007. If you are looking for ruby on rails developers in india, then contact us at: info@cryptextextechnologies.com

    ReplyDelete
  7. After reading this blog i very strong in this topics and this blog really helpful to all... explanation are very clear so very easy to understand... thanks a lot for sharing this blog more info on Ruby on Rails Online Training

    ReplyDelete
  8. Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. ROR Development Company India,

    ReplyDelete
  9. I’m trampled by your contents carry on the wonderful work. array

    ReplyDelete