similar to: Better way to count Active Record Data?

Displaying 20 results from an estimated 10000 matches similar to: "Better way to count Active Record Data?"

2009 Sep 07
11
autoincrement for non-id column
There is a table: execute (<<-SQL) CREATE TABLE "tasks" ( "id" serial primary key, "number" serial, "version" integer DEFAULT 0 NOT NULL, "latest_version" boolean DEFAULT ''t'' NOT NULL, "hidden" boolean DEFAULT ''f'' NOT NULL, "type" character varying (1) NOT
2010 Sep 07
2
Help on formatting some HAML
I wondered if anyone could help me with turning the following in ERB into HAML. I''m VERY new with HAML: ---- <div class="block-element span-7 colborder"> <span class="rightside blue-hue no_decor"><%= link_to "New Order", new_order_path, :remote => true %></span> <h3>Today''s Activity</h3> <hr>
2011 Jan 20
4
Comment.all returns array of what?
I have a bad feeling asking this but I did not manage to find an answer myself :/ @comments = Comment.all @comments is an array. I can for example access comment.created_at directly, or I could do: <% @comments.each do |comment| %> <%= debug comment["created_at"] %> <% end %> I expected comment to be a hash, but comment.keys or comment.values fail, as well as an
2010 Dec 09
15
Rails 3 Active Record query returns "undefined method `loaded?' for #<Array:0x126a4c>"
I am getting this error on an rspec test: undefined method `loaded?'' for #<Array:0x126a4c> When I call: Practice.includes("practice_members").all Practice has_many :practice_members PracticeMember belongs_to :practice Practice.all returns: [#<Practice id: 6, name: "Practice One", created_at: "2010-12-09 15:40:46", updated_at: "2010-12-09
2010 Dec 20
11
rails code to sql
Is there a relatively easy way to do this code in sql? @categories=Category.all.reject{|n| n.blank?}.sort{|a,b| a.name <=>b.name}.collect{|t| [t.name,t.name.downcase.gsub('' '',''_'')]} -- 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
2009 Oct 14
6
Combining rails intrAnet and public site.
Hello, everyone! I was wondering if somebody has some insight on this issue. [h]A little background:[/h] I work for a midsize electronic manufacturing company with 2 people in IT dept - a network admin and a developer (me). We''ve been using rails to migrate from an old dBase and VB based system to build internal company IntrAnet that does things like label printing, invetory control,
2010 Dec 23
36
Weird issue with converting floats to integer
Any idea why this calculates the integer the way it does? irb> ("291.15".to_f * 100.0).to_i => 29114 Thanks, Tom -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2009 Jun 22
5
has_many through , or habtm , using form
i think there ara two ways of relate products and categories , basically i want to fix one product(e.g hp dv7....) to some categories (notebook,17"notebooks...) i made a table named categorization(incuding category_id,product_id fields) then in models i write these codes below class Product < ActiveRecord::Base has_many :categories, :through => :categorizations
2010 Dec 14
4
Change primary_key column name
Hi, after changing a primary key column name, the auto-increment information (MySQL) and sequence (Oracle) are lost. What is the correct way to rename primary keys? Thanks, Gustavo -- 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
2009 Oct 27
14
Authlogic Password confirmation is too short Error. NEED HELP.
Hi: I am using authlogic, and following railscast tutorial. I am running into this error code with the password confirmation. authlogic password confirmation is too short Has anyone experienced this error? I need your help. Thanks in advance for your help.
2010 Aug 30
16
<b> tag in HTML 5 (was Re: Re: assert_select for <p><b>text</b>value</p>)
On 30 August 2010 15:47, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > Colin Law wrote: >> I have the following html >> <p><b>text</b>value</p> >> I can use >> assert_select "p>b", "text" >> to check the text portion, and >> assert_select "p", "value"
2009 Aug 19
10
acts_as_list / acts_as_tree / acts_as_nested_set - which one
I am creating forum application which needs usage of acts_as_list or acts_as_tree or acts_as_nested_set. I am unable to decide among these. please could some one recommend from their experience? -- Posted via http://www.ruby-forum.com/.
2009 Aug 13
10
default value if textfield is empty
Hey all, im not sure where to set a default value if a textfield is empty? For now i do it in the controller, and check if the submitted parameter is blank. But this seems not to be the best solution... Thanks for your help! -- Posted via http://www.ruby-forum.com/.
2010 Dec 15
6
Mysql query optimization for order condition
Hello everyone! I''ve a question that I hope someone in here would be able to answer. Today I was writing a simple test for a method that takes the last "n" (where n is an integer) users that signed up on my web app. I know it''s a simple method, but then I started to think about the optimal way to query the DB, and I tried different options. The first thing I did
2011 Jan 06
14
Forceing PUST vs. POST in form
I am experimenting with a combined form. I wish to force the HTTP verb for this form to PUT. However, it always uses POST when submitted and I cannot determine why. The view template code is: <%=form_for( @user, :html => { :class => :edit_user_role, :id => :edit_user_role_form, :method => :put }, :url => user_roles_url( @user ) )
2009 Oct 20
10
REXML
Hi, How to embed ruby code in xml . here is my XML template : string = <<EOF <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ozxmlscene> <ozml version="4.0"> <styleRun style="1091379" offset="0" length="7"/> <text>The End</text> <object value="84"/> <object
2010 Dec 21
8
Rails - escape_javascript without all the \n\n\n\n\n
Hello, I''m using escape_javascript to return a partial to the browser via ajax. Something like: $("#inject").html("<%=escape_javascript(render :partial =>"feed/ index")%>"); Problem is escape_javascript ends up outputing all kinds of wasted space like \n\n\n\n\n \n Is there anyway in Rails to escape_javascript more
2010 Jun 14
7
"NoMethodError in AdminController#index" error
hi, im totally a newbie so i have got no idea whatsoever why i got this error, the thing that happend was i was doing a little coding along with the lynda.com rails series that i got this error. well as u can see this is the error which i get on terminal, but there is another one in browser too which says : "NoMethodError in AdminController#index " u can see it in the picture here :
2009 Nov 01
9
Dynamic Database Connections
Hey everyone! I have a problem that''s been making me a little nuts. I would like to use RoR for a upcoming project, but if I can''t get past this hiccup I''m afraid I''ll have to use PHP or Java. Ugh. The application needs to have a database-per-customer model. So when I do a Product.find(:all) I need to make sure i''m connecting to say acme.products
2010 Oct 27
4
Anything special needed to migrate test::unit tests from Rails 2x to Rails3?
Looks like I''ve gotten my app upgraded successfully, at least in the browser. When I ''rake test'' I get no love. I know I can start digging through the Rails rake tasks, first want to see if anyone has an idea what is going on: DKMac:creditcompare3 DK$ rake test (in /Users/DK/Documents/ror/projects/creditcompare3) DKMac:creditcompare3 DK$ (requesting verbose fares just