similar to: ActiveRecord, using sql functions for some attributes

Displaying 20 results from an estimated 700 matches similar to: "ActiveRecord, using sql functions for some attributes"

2006 Aug 10
4
Speeding up ActiveRecord creation?
My completely empty model (no validation callbacks etc etc) takes an average of 0.05 seconds to create, at least according to Benchmark.realtime{200.times{Message.create(:from => "me@here.com", :message_type => ''email'', :subject => "hello", :body => "goodbye", :sent_at => Time.now)}}/200 That''s a little slower than
2006 Aug 18
1
customization of ActiveRecord models
I''m trying to determine how/if I can use MySql''s spatial extensions with ActiveRecord. The spatial extensions usually require inserts in the following format: INSERT INTO `locations` (name, point) VALUES ("location name",GeomFromText(''POINT(<lng> <lat>'')); And reads as SELECT name, AsText(point) AS point FROM locations; While I
2006 Jul 14
1
ActiveRecord, can it save more than one row at a time????
Hi, I wonder if there is some fonctions which allow an activeRecord to save more than one row at a time??? As I understand, when we create an object from AC::Base, it represents one row of the table. So if I want to save more than one row, I have to create the object one by one and then save them one by one. If I have 10, it is fine, but if I have more than 1000, so it will a lot of time.... So
2006 Apr 06
2
using select() to relate tables
I''m sorry to be asking trivial questions, but I''m new to RoR and am hooked :), so I''m very impatient to get things up and running. given two related tables, "pcs" and "venues" (venues have many PC''s and each PC belongs to one venue only) I can use a select() to present venue names in the "new PC" form along with other PC details to
2006 Jul 05
3
splitting a story with double-spaced para''s
Quick question - if i want to separate a long string of text, separated by single carriage returns, into an array of paragraphs, I can use the following code: paragraphs = article.content.split("\n") The "\n" means a carriage return, as far as I can tell. If I wanted to take text, that had been written using the more common double carriage returns, into an array of
2006 Apr 06
6
select method
The documentation states as an example: select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) could become: <select name="post[person_id]"> <option></option> <option value="1" selected="selected">David</option> <option
2006 Aug 18
4
Button on view
Hi, I have a page containing 3 views (2 are partials). One of the partials needs to have a button that will clear a table called "messages" in the database. I can put a button like this "<%= button_to "Clear Messages", :action => ''clear_messages'' %>" and have the controller do "Message.delete_all". But the problem is that the
2006 Apr 05
25
How to avoid bunch of <% %> ??
Hello, I would like to know is there is a way to avoid poluting the views with tons of <% %> ? Like this <%= start_form_tag() %> <%= text_field_tag(''category[title]'', category.title, {:size => 20, :maxlength => 128}) %> <% if not category.parent_id.nil? %> <%= select("category", "parent_id", Category.find(:all,
2006 Jul 05
1
time.next_week bug?
i ran into an error today when dealing with the method next_week and daylight savings time... >> Time.local( 2006,10,23 ).next_week => Tue Oct 24 00:00:00 EDT 2006 Any one know if this is a know issue or should a ticket be created for this issue? thanks for the help mark -- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com -------------- next part -------------- An HTML
2006 Jul 03
13
Eager loading ActiveRecord objects
I have a complex graph of ActiveRecord entities that I want to load with one big honkin'' join query to avoid ripple loading. It''s for a report. However :include doesn''t get me all the way there because I want to load parents of parents (or children of children). I don''t mind doing the SQL by hand but I''m not quite sure what to do to get the result
2006 Apr 11
26
Firefox won''t let me send ''&'' with AJAX!
Hi everyone, I''ve encountered a HUGE problem, which may not be RoR-oriented, but there might be a workaround somehow. See, at this moment, I''m unable to send AJAX requests back and forth when the information contains an ampersand (''&''). In essence, request is never completed. The odd thing is that it only happens with Firefox (IE and Opera works fine).
2006 Jun 24
4
setting attribute in constructor, .NEW works but not .CREATE
I have table "decks" with three fields: "id", "created_at" and "cards" which is a 264-character string field. I have modified the model with a constructor, as follows: class Deck < ActiveRecord::Base attr_reader :cards def initialize @cards = "12345" end end If I call Deck.new from my controller, I get no errors and an object with the
2006 Jul 03
2
Still struggling with data flow ...
Hello, The following view: <%= start_form_tag %> Enter term to find <p> <%= text_field_tag :name, params[:name] %> </p> <%= link_to "Find", { :action => ''find_term''} %> <%= end_form_tag %> does not appear to pass back the value of :name to the action: def find_term term =
2006 Jul 05
2
splitting a paragraph into words and spaces
I''m using this: <% words = article.content.split(/ /) %> <%= words[0..20] %> to (ostensibly) split a paragraph into component words, with spaces in between, then print to html only the first 20 items, words and spaces. I got this (split(/ /)) from the online pickaxe book at http://rubycentral.com/book/ref_c_string.html#String.split . The problem is, the resulting array
2006 Apr 07
2
ActiveRecord find all based on array -- need ids from array
Does anyone know if it is possible to perform an ActiveRecord find by passing in an array? I would like to be able to do the following: MyModel.find(:all, :conditions => ["user_id in (?)", users]) The problem I run into is that the returned SQL contains the to_s() output of the User object, not the ids of those users. Is it possible to change this behavior? I attempted to
2006 Aug 17
2
RJS - slower than normal RHTML?
I know that isn''t supposed to be the case, and it usually isn''t, but today, I''ve run across a situation where rendering the same partial through RJS is taking about 5 times longer than rendering the partial in the RHTML. I have in my main RHTML <tbody id="account_transactions"> <%= render :partial =>
2006 Aug 07
2
converting pdf to images
i am working on a catalog for our customers to order printing. i have worked a little bit with imagemagick and pdf_writer. currently i am uploading a pdf and an image for the preview of the file. i''m just wondering if there is a way to convert a page of the pdf to a jpeg so that i only have to upload once. -- Posted via http://www.ruby-forum.com/.
2006 Aug 15
1
Question on start_form_tag and get post method
Hi all, I have a simple question about start_form_tag. It default generates method=post. I was wondering how you could use start_form_tag to generate method=get. Probably a simple question but one I can''t answer with the API doc. Thanks in advance, Onno
2006 Jul 03
1
Print link or button?
Is it possible to create an action that would sent a view straight to a printer or a button of some sort that would enable the view to be printed. Currently the user has to click on file and then on print in the browser to print. My users would like to be able to click on a link or button and have the view printed. Is such a thing possible? And how would one do it? Thanks, Paul
2006 Jul 04
1
options_for_select - default nil value
I have a field in a view, like so: <%= select_tag(''quoted_condition'', options_for_select([''NEW'',''RETAIL'',''OEM'',''REFURB''], ''NEW'')) %> This sets the ''selected'' value to ''NEW'' - however, I would like to have a nil value here, so I can