Displaying 20 results from an estimated 1000 matches similar to: "ActiveRecord, computed values, and associations"
2005 Dec 29
0
observe_form without an update parameter
I''m using observe_form in a place that does not require any response
from the server. So I do not use an update paramater. But without it
webbrick hangs for a couple seconds and returns a status 500. On
occasion, there will even be an exception in webbrick''s output if I
change the form then quickly click a link before the couple second hang
is done. If a add an update, it
2006 Feb 16
5
Firefox and IE performance with Rails App
In my rails application, certain computers were having huge problems.
There were certain pages that were exceptionally slow, even to the point
of timing out. Other computers did not have a problem. I finally found
that Firefox was the difference. When using Firefox on those computers
it works fine. The slow pages were typically posting a form with a
couple hundred fields.
This behavior was
2007 Nov 15
4
Using .find_by_sql for database/admin queries
I want to create an internal admin view to display the output of "show
variables" from mysql. What''s the best approach do this?
For example, I''m doing something like this:
@variables = ActiveRecord::Base.find_by_sql "show variables;"
Then, I get stuff like this back (227 elements in @variables) in
script/console:
>> @variables[0]
=>
2006 Apr 20
3
has_many :through with has_many/has_many join models
It seems that using a join model that joins with two has_many''s will
fail to generate proper SQL
class StudentSemesterRecord < ActiveRecord::Base
belongs_to :semester
has_many :discipline_records, :through => :semester
end
class Semester < ActiveRecord::Base
has_many :student_semester_records
has_many :discipline_records
end
class DisciplineRecord <
2005 Dec 15
3
define_method with parameters
Hi,
I''m trying to write a macro which defines methods. One of these should
have a parameter, but I can''t get that to work. Something like:
define_method("printstuff") do
puts "blabla"
end
works fine. But, how do I use define_method to create something like:
def printstuff(the_stuff)
puts the_stuff
end
Thanks in advance.
2006 Feb 03
6
Go back to previous action
Hello all!
I have two views (list_1 and list_2) that show a list of users in two
different ways. In the views for these actions there is a link to edit a
specific user properties (edit_user). That works fine, except that when
I change the user I want to go back to the view that originated the
request and not to the default list (list_1).
Can anyone help me?
Best regards,
Hugo
--
Posted via
2006 Jan 15
6
PROPOSAL: Validations as Mixin
It seems to me that Validations are quite useful for many objects, even
ones having nothing to do with ActiveRecord.
Common examples are Contact Us forms, multi-step forms, web service
paramater validations, etc.
I took a look at the source for Validations, and it seems that it is
very independent from ActiveRecord. I caught only three depenedencies:
1. validates_numericy --> depends on
2009 Sep 28
3
rjb: Java classes in Rails
Hi,
For those who might not be aware, rjb is a killer gem for using java
classes inside your rails app (or any ruby code). Check it out at:
http://rubyforge.org/projects/rjb/
I was able to successfully use it in one of my apps that required some
code that is only available in java. And it''s much nicer than having to
compile a java app, then shell out using backticks, get back the return
2006 May 23
8
ad-hoc query
How do you run an ad-hoc query that does not belong in any model? I
thought it was something like ActiveRecord::connection.find("my
query..."), but I can''t seem to find the documentation on it. I know
I''ve seen it somewhere before, though.
thanks,
Jeff
--
Posted via http://www.ruby-forum.com/.
2006 May 30
6
How to solve "Marshal Data Too Short" error?
Hi
I''ve got the error in the log file "marshal data too short" after I try
to store some data into session.
After doing some research on the internet, it looks like the problem was
caused by pstore.rb. It is there way to solve this problem?
Thank you
--
Posted via http://www.ruby-forum.com/.
2005 Oct 19
35
Why you MUST use SCGI for Rails development
Hello happy Railers,
I used to develop with a local out-of-the-box Apache and load times were
pretty slow (like a few seconds each page). "Well, it''s the price to
pay for no compile / cache / etc..." I thought. Nonsense. Yesterday I
installed SCGI, and now I''ve got the best of both worlds: rails
development env uses my very latest modifications, while SCGI ensures I
2006 Mar 28
0
Problem with folder redirection and "guest user"
Hi all,
I am setting up my second server with Samba 3.0.21c with LDAP as described in
Samba3-ByExample. The server OS is Slackware Linux 10.2, without PAM.
All seemed to work perfect until I decided to try folder redirection.
I followed the instructions given in the "happy users" chapter, but now new
users cant log in. When trying to log in with a new user (umgrtest16) from a
WinXP SP2
2007 Jun 05
4
uninitialized constant RailsHandler::Dispatcher
Hello,
I am running in to an error trying to run mongrel. The server starts but
then trying to access any url in my application throws this error:
calling Dispatcher.dispatch uninitialized constant RailsHandler::Dispatcher
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:477:in
`const_missing''
2005 Dec 21
7
use of SET command in find_by_sql
Hi,
I''m trying to execute something like this method in a model:
def self.sql_for_rankings()
sql = "SET @counter:=0;"
sql << " SET @counter:=0;
SELECT *, @counter:=@counter+1 AS rank
FROM testscores. "
find_by_sql(sql)
end
Where the new rank column is a kind of autoincrementer inside of
2006 Jul 17
1
How to DRY up validates_presence_of
Given the case of validating the presence of an attribute and then
performing other tests on said attribute, how do you go about not having
to check for nil in the other tests?
Example:
validates_presence_of :start_date, :end_date
validate :validate_start_date_before_end_date
def validate_start_date_before_end_date
# without this check an exception will be thrown on access to the
2006 Apr 29
1
Warnings printed to console causes error if console closed on Linux
I had a statement that was generating a warning about parenthesise
argument for future version. The interesting thing was it would crash
the page with an input/output error on my production linux server, but
worked fine in webbrick/windows. I finally tracked it down to it crashed
when trying to print the warning to the console. If I kept the terminal
open that I started the server on it would
2007 Aug 14
1
find_by_sql vs connection.select_all
I was trying to do SUM based mySQL query simliar to the following:
SELECT SUM(updated_on - created_on) AS total from signups
If I were to run this command in the mySQL console I would get a
result. However, if I were to run it using the following command in
Rails:
Signup.find_by_sql("SELECT SUM(updated_on - created_on) AS total from
signups")
The query that is written to the log is:
2007 May 21
7
How do I stop a column being updated by model.save?
One of my models has a column that is updated very frequently from a
separate process, so it is important that when a record is saved in
rails, this column should be left alone. In the update method of the
controller I have:
@record = MyModel.find(params[:id])
@record.update_attributes(params[:my_model])
params[:my_model] doesn''t have a reference to the column I''m talking
2006 Apr 20
1
has_many.count not accepting options hash
has_many.count does not seem to support an options hash like
ActiveRecord::Base.count does.
Example:
>> AcademicProgram.find(:first).course_requirements.count :conditions
=> "courses.name LIKE ''a%''", :include => :course
=> 40
>> ap.ap_requirements.count :conditions => "courses.name LIKE ''a%''",
:include =>
2006 Aug 10
1
Customizing log output
I''d like to include the user name along with/instead of the session id
in my log files. Is there a place to customize the log format, or do I
just need to through the logger object and manually write it in a
before_filter on my ApplicationController?
Thanks.
--
Jack Christensen
jackc@hylesanderson.edu