Search Results

Search found 16 results on 1 pages for 'kandadaboggu'.

Page 1/1 | 1 

  • How do I call a super class method

    - by KandadaBoggu
    I have two classes A, and B. Class B overrides the foo method of class A. Class B has a bar method where I want to call the foo method of the super class. What is the syntax for such a call? class A def foo "hello" end end class B def foo super + " world" end def bar # how to call the `foo` method of the super class? # something similar to super.foo end end

    Read the article

  • Encoding error PostgreSQL 8.4

    - by KandadaBoggu
    I am importing data from a CSV file. One of the fields has an accent(Telefónica O2 UK Limited). The application throws en error while inserting the data to the table. PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xf36e6963 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". : INSERT INTO "companies" ("name", "validated") VALUES(E'Telef?nica O2 UK Limited', 't') How do I workaround this issue?

    Read the article

  • Self documenting REST interface

    - by KandadaBoggu
    I have a Rails based server running several REST services and a Rails based web UI that interacts with the server using ActiveResource. Same server is being used by other clients( e.g: mobile). I have to generate documentation for the REST interface. I need to provide service URL, input/output and error document structure for each service. Ideally, I would like to use an interceptor at the server side that will document the service based on the existing traffic. I am wondering if there is a gem to do this.

    Read the article

  • Amazon S3 enforcing access control

    - by KandadaBoggu
    I have several PDF files stored in Amazon S3. Each file is associated with a user and only the file owner can access the file. I have enforced this in my download page. But the actual PDF link points to Amazon S3 url, which is accessible to anybody. How do I enforce the access-control rules for this url?(without making my server a proxy for all the PDF download links)

    Read the article

  • ERB Template removing the trailing line

    - by KandadaBoggu
    I have an ERB template for sending an email. Name: <%= @user.name %> <% unless @user.phone.blank? %> Phone: <%= @user.phone %> <% end %> Address: <%= @user.address %> When the user hasn't set the phone then the email body is as follows: Name: John Miller Address: X124 Dummy Lane, Dummy City, CA I am trying to remove the blank line between Name and Address when Phone is empty. Name: John Miller Address: X124 Dummy Lane, Dummy City, CA I have tried to use <%--%> tags(to remove the trailing new line) without any success. Name: <%= @user.name %> <%- unless @user.phone.blank? -%> Phone: <%= @user.phone %> <%- end -%> Address: <%= @user.address -%> How do I work around this issue?

    Read the article

  • What is the equivalent of REGEXP_SUBSTR in mysql?

    - by KandadaBoggu
    I want to extract a word from a string column of a table. description =========================== abc order_id: 2 xxxx yyy aa mmm order_id: 3 nn kk yw Expected result set order_id =========================== 2 3 Table will at most have 100 rows, text length is ~256 char and column always has one order_id present. So performance is not an issue. In Oracle, I can use REGEXP_SUBSTR for this problem. How would I solve this in MySQL?

    Read the article

  • Max value amongst 4 columns in a row.

    - by KandadaBoggu
    I have test_scores table with following fields: Table schema: id (number) score1 (number) score2 (number) score3 (number) score4 (number) Sample data: id score1 score2 score3 score4 1 10 05 30 50 2 05 15 10 00 3 25 10 05 15 Expected result set: id col_name col_value 1 score4 50 2 score2 15 3 score1 25 What is a good SQL for this?(I am using MySQL.)

    Read the article

  • How to override the attr_protected?

    - by KandadaBoggu
    I have STI implementation as follows: class Automobile < ActiveRecord::Base end class Car < Automobile end class Truck < Automobile end class User < ActiveRecord::Base has_many :automobiles accepts_nested_attributes_for :automobiles end I am creating a list of automobiles for a user. For each automobile, the UI sets the type field and the properties associated with the automobile.While form submission, the type field is ignored as it is a protected attribute. How do I work around this issue? Is there a declarative way to unprotect a protected attribute?

    Read the article

  • How to add additional condition to the JOIN generated by include?

    - by KandadaBoggu
    I want to add additional criteria to the LEFT OUTER JOIN generated by the :include option in ActiveRecord finder. class Post has_many :comments end class Comment belongs_to :post has_many :comment_votes end class CommentVote belongs_to :comment end Now lets say I want to find last 10 posts with their associated comments and the up comment votes. Post.find.all(:limit => 10, :order => "created_at DESC", :include => [{:comments => :comment_votes]) I cant add the condition to check for up votes as it will ignore the posts without the up votes. So the condition has to go the ON clause of the JOIN generated for the comment_votes. I am wishing for a syntax such as: Post.find.all(:limit => 10, :order => "created_at DESC", :include => [{:comments => [:comment_votes, :on => "comment_votes.vote > 0"]) Have you faced such problems before? Did you managed to solve the problem using the current finder? I hope to hear some interesting ideas from the community. PS: I can write a join SQL to get the expected result and stitch the results together. I want to make sure there is no other alternative before going down that path.

    Read the article

  • Grid forms in Rails

    - by KandadaBoggu
    I am trying to create a grid form for a survey question. value1 value2 value3 option 1 x option 2 x option 3 x Each cell in the grid is a radio button and the radio buttons in a row belong to one radio button group. My models: class Question # title has_many :answers end class Answer # name, position, atype(row/col) end I am struggling to come up with a Rails approach for creating such a form. To complicate the issue user can save the semi-completed form and complete it at a later time. What is the best approach for this problem?

    Read the article

  • Ordering view by highest group count question - Ruby on Rails

    - by bgadoci
    I've read the couple of questions about this on stack overflow but can't seem to find the answer. I am trying to display the tags in my blog by the ones with the highest count in the tags table. Thanks to KandadaBoggu for helping me get the tags feature of the blog I am designing working. Here is the basics and my question. Tag belongs_to :post and Post has_many :tags. The tags table is simple really, consisting of the normal scaffolded fields plus post_id and tag_name (I actually called the column 'tag_name' instead of just 'name'). in my /views/posts/index.html/erb file I correctly am displaying the tags by group and the amount of times they are being used (appearing in the tags table). I just want to know how to order them by the highest count. Here is the code, and I currently have it set to updated_at: PostsController def index @tag_counts = Tag.count(:group => :tag_name, :order => 'updated_at DESC', :limit => 10) conditions, joins = {}, nil unless(params[:tag_name] || "").empty? conditions = ["tags.tag_name = ? ", params[:tag_name]] joins = :tags end @posts=Post.all(:joins => joins, :conditions=> conditions, :order => 'created_at DESC').paginate :page => params[:page], :per_page => 5 respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } format.json { render :json => @posts } format.atom end end

    Read the article

  • link_to passing paramater and display problem - tag feature - Ruby on Rails

    - by bgadoci
    I have gotten a great deal of help from KandadaBoggu on my last question and very very thankful for that. As we were getting buried in the comments I wanted to break this part out. I am attempting to create a tag feature on the rails blog I am developing. The relationship is Post has_many :tags and Tag belongs_to :post. Adding and deleting tags to posts are working great. In my /view/posts/index.html.erb I have a section called tags where I am successfully querying the Tags table, grouping them and displaying the count next to the tag_name (as a side note, I mistakenly called the column containing the tag name, 'tag_name' instead of just 'name' as I should have) . In addition the display of these groups are a link that is referencing the index method in the PostsController. That is where the problem is. When you navigate to /posts you get an error because there is no parameter being passed (without clicking the tag group link). I have the .empty? in there so not sure what is going wrong here. Here is the error and code: Error You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.empty? /views/posts/index.html.erb <% @tag_counts.each do |tag_name, tag_count| %> <tr> <td><%= link_to(tag_name, posts_path(:tag_name => tag_name)) %></td> <td>(<%=tag_count%>)</td> </tr> <% end %> PostsController def index @tag_counts = Tag.count(:group => :tag_name, :order => 'updated_at DESC', :limit => 10) @posts=Post.all(:joins => :tags,:conditions=>(params[:tag_name].empty? ? {}: { :tags => { :tag_name => params[:tag_name] }} ) ) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } format.json { render :json => @posts } format.atom end end

    Read the article

1