Michael J. I. Jackson wrote:
I'm running Rails on top of a Mongrel cluster. I have several model
classes that are going to have so many records it is not feasible to
keep them all in the same table. So I've split out the records into
many different tables, each with its own suffix
Richard wrote:
Is this possible ??
Yes, but only with custom SQL:
Model.connection.insert replace into #{Model.table_name}
--
Rails Wheels - Find Plugins, List Sell Plugins - http://railswheels.com
--~--~-~--~~~---~--~~
You received this message because
Chris wrote:
I just finally figured out how to get 2.2.2 to do this, and thought
I'd share in case others run into the same thing.
...
:joins = AND
key_factors.entity_id=+...@entity.id.to_s,
This find specification gets the job done, but it's a pretty nasty
Alex Fortuna wrote:
I need to execute a SET SQL_MODE='STRICT_ALL_TABLES' after my
application's DB connection is established by AcriveRecord. This is
important since I want the DB itself be more strict about logical data
integrity.
Which is the proper place within application code from
Chris Warren wrote:
How do you dynamically set the association conditions? I've done a fair
amount of programming, but am new to RoR - I abandoned that approach
because I thought the conditions were fixed when the object was defined.
dino d. wrote:
def self.set_current_user user
if user
holder = user.id
else
holder = -1
end
reflect_on_association(:current_user_vote).options[:conditions] =
votes.user_id = #{holder}
self.current_user = user
end
This works fine, unless I
xeon wrote:
Hi,
I would like to know for each running model action, how can I retrieve
the SQL running behind? I don't want to scan log each time for the sql
running behind.
E.g. post.find(:all,:conditions={:id='1'}
I wanna debug the sql generated behind, is that other shorthand
Srividya Sharma wrote:
Hello
I am using Rails 2.2.2.
Here is my problem:
I have a controller action which will receive several parameters,
validate them, process them and create a new set of parameters out of
them.
Then, this controller should delegate the task to another controller
Sergio Ruiz wrote:
,[ worker ]
| class Worker ActiveRecord::Base
| has_and_belongs_to_many :skillsets
| belongs_to :instructor
| end
...
| %= collection_select(:worker, :skillsets, Skillset.find(:all), :id,
:title, {}, {:multiple = true}) %
...
+ when the select box is
Farrel wrote:
I'm on Rails 2.2.2 on MySQL with InnoDB table types. I'm running into
a wierd bug where if I have two models in a transaction and the second
model raises an exception, the first model still has it's ID set and
it's new_record status set to false despite the row the ID is set to
Adriano Lul wrote:
I would like to show messages when the validation fails (must be number,
cant be blank, etc) but not in the main page I would like to open a pop
up or better yet put it in a confirm screen where user would read and
thereafter click ok.
render :update do |page|
if
Raimon Fs wrote:
Hello,
I have a page with a form and a div area that I update after submitting
the form.
I want to replace the Div area with new information.
In the page, inside the div area, I have:
div id=div_list
%= render :partial = list %
/div
as I want to show the
Dan Smith wrote:
I have a form which lets users upload an flv file to the database, this
should then be played by the player.swf file in the public directory.
src=/player.swf?... should work
--
Rails Wheels - Find Plugins, List Sell Plugins - http://railswheels.com
dino d. wrote:
I've dramatically improved my SQL performance with eager loading, but
the problem is, it kills the :select directive because it generates
its own (it ONLY selects the table fields and eager loaded table
fields). Is there a way around this? I have some left outer joins in
Nate Leavitt wrote:
Is the thread specific for the request in rails? Meaning.. the
before_filter will be run on each rails action/request therefore is a
new thread created in rails for that process? Jeez.. I hope I'm
explaining it properly :)
Yes, each thread only carries one request at
Camille Roux wrote:
I've a question about the Rails runtime.
I'd like to know which part of Rails is executed (and put in memory) at
each request? at each server launch?
In other words, is Rails like PHP (the whole code is executed at each
request)?
On on start-up in production mode a
Pardee, Roy wrote:
%= observe_field('project_search',
:url = { :controller = projects, :action = index_search},
:update = project-list,
...
That partial renders a table w/one row per project. This works just fine
from FireFox. But from IE I don't get my table--just a blank
Jared Moody wrote:
I have a form that allows a User to add/edit the additional Users or
LoginUsers to/on their account, but the wrong validations are run when
updating a User to be a Login user or vice-versa.
...
# revoking login privledges
if @user.is_a?(LoginUser)
Nate Leavitt wrote:
Is that multi-thread safe for the newer versions of rails?
Yes.
--
Rails Wheels - Find Plugins, List Sell Plugins - http://railswheels.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Nate Leavitt wrote:
First off, I'm an intermediate Rails developer who is still learning the
inner workings of Rails.. so here is my situation/problem:
I have written a Plugin that accesses a third party API. Within the
Plugin I had multiple classes that inherit from one another. Example:
Macario Ortega wrote:
The problem is that the Photos don't get saved in the database although
they return false for #new_record? and Paperclip saves the files, if I
set a debugger here:
def create
@page = Page.new(params[:page])
if @page.save
...
else
Panda Beer wrote:
Hi all ,
I have a habtm relation between 2 tables:
- users
- rights
If there a way to affect a destroy dependance on those 2 tables only for
the last instance? In my opinion, dependent = :destroy is not the
solution because this delete all the linked instance.
Paul Nelligan wrote:
I want to use this plugin for a many-many relationship with a join
table, with one of the models being enumerated... does it still hold the
same benefits with respect to caching??
Sure. All instances will have their attributes cached, but the
association will also be
David Sousa wrote:
Hello Mark, thanks... but, my problem is bigger than that or I don't
know how that the answer is easy.
So, I have a structure like this. (view)
div id=my_client_list
% @client_list.each do |client| -%
%= client.name%
... .. .. .. ..
%
elioncho wrote:
User.find_by_sql update users set name='Test'
Use User.update_all ['name = ?', 'Test']
or User.update update users set name='Test'
--
Rails Wheels - Find Plugins, List Sell Plugins - http://railswheels.com
--~--~-~--~~~---~--~~
You received
anton effendi wrote:
Thank you..
Your ide must use 3 model.. 1 model - User, 1 model - for admin, 1
model - for user
is true?
But I want use 1 model for admin and user..
so if I call user = User.create in admin and in user, photo will
upload.. with different size thumbnail.
Can u
Adam Akhtar wrote:
Is it possible to pass predefined arguments along with a form with
form_for? i.e. an id etc?
I have a task model with usual title, completed(bool), duedate and a
foreign key field called project_id (a project has many tasks). On one
view i want to have an express add
anton effendi wrote:
I want to make upload photo with attachment_fu.
this logic is
if admin
has_attachment :content_type = :image,
:storage = :file_system,
:path_prefix = 'public/photos',
:processor = 'Rmagick',
David Sousa wrote:
Hello there,
I'm trying to do something like:
render :update do |page|
page[:client_list].replace_html render(:partial = 'client_list',
:object = @clients_list)
name = page[:name].getValue();
end
but I'm not getting the value, or somehow use
Fritz Anderson wrote:
The application is not full Rails; it has no ActiveController instances.
That'll mean you'll miss out on Rails automatic connection verification.
You might like to call Message.verify_active_connections!
before your find.
An interesting proposition.
Mattias Bud wrote:
`real_connect': Unknown database 'dbname_production' (Mysql::Error)
Does this exist, or do you want to use the dbname_development database
by leaving the -e production option off the runner command?
--
Rails Wheels - Find Plugins, List Sell Plugins -
Kyle Wakefield wrote:
If not, does someone know what I could be missing in my Apache
configuration that is keeping me from accessing development mode?
Are you using Passenger (mod_rails)? If so, you need to add the
RailsEnv development option to your VirtualHost config.
--
Rails Wheels -
Michael Graff wrote:
I am willing to give up the common denominator in database
compatibility and dive into using some PostgreSQL specific types. In
particular, I need bigint (int8) id columns and 'cidr' data type.
Can't help you on the cidr, but to change the id to bigint I've used
Mattias Bud wrote:
I have some jobs running through cron jobs and runner that suddenly
starts failing.
This is how it looks:
from
/usr/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/commands/runner.rb:47
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
Fritz Anderson wrote:
Periodically my application (a faceless daemon, so there's no
human-interface considerations) gets the following exception:
Mysql::Error: MySQL server has gone away: SELECT * FROM `messages` WHERE
(`messages`.`disposition` IS NULL) ORDER BY senttime
Dan Smith wrote:
Hi, I have a model which contains a boolean value. I would like to set
a validation which only allows this value to be set to true for one
record at a time in the table. Is it possible to do this with
validates_uniqueness? or is there another way?
validates_uniqueness_of
adamfowleruk wrote:
I recently wanted to come up with a solution to searching by a
category (E.g. Shoes), sub category (E.g. Shoes Blue), or sub sub
category to any depth. This represents an obvious DB challenge not to
mention model objects in RoR. I've come up with an elegant solution
Have you tried downloading the rubygems 1.3.1 source
from http://rubyforge.org/frs/?group_id=126 , unpacking,
then running ruby setup.rb as root in that directory?
--
Rails Wheels - Find Plugins, List Sell Plugins - http://railswheels.com
--~--~-~--~~~---~--~~
Tom Hoen wrote:
I am using subdomains in my application to control context. Therefor,
during user registration, password reset, and other actions that require
an email to be sent with a link to be clicked, I need to ensure that the
subdomain appropriate for the user is used.
It seems I
Tom Hoen wrote:
Mark Reginald James wrote:
You'll have to supply the request object as a parameter to
mailer calls made in your controllers.
Mark, I appreciate the quick response.
Unfortunately, I am using an Observer to initiate the emails. So I don't
think I have access
Jason Pfeifer wrote:
Greetings, I have a method from which I want to generate CSV files based
on the model name:
def export_table_to_csv(table)
require 'csv'
@table = table
@results = @table.find(:all)
@titles = @table.column_names
report = StringIO.new
Jason Pfeifer wrote:
So if I have that correct, I don't understand how the send method
operates on the result object. Is it just passing a method name? I
guess I was just mistakenly thinking of it in terms of key value
pairing:
result.send(a) AS result[a]
result.send(a) just calls
Ben Johnson wrote:
Category.has_many :products
Let's say a product must belong to a category. I know it is recommended
to do the following:
class Product
validates_presence_of :category_id
end
But, as we all know, this is a pain for new records, meaning what if the
associated
Terpinator wrote:
I have one method, 'updateStuff', that will call 'update_attributes'
on 3 different models in the DB.
How can I account for validation to revert back all updates if one of
the models is not valid?
Note that you want all-or-nothing DB updates, but, for purposes
of
bigsley wrote:
So is this a known bug? Is this fixed in 2.2.2? I'm currently running
rails 2.1.1.
The issue is present in 2.2.2, and probably edge.
I'm looking into a fix, but as Fred says, there are
several subtleties. I suggest you watch this ticket:
Elliott Blatt wrote:
Hi,
I'm using attachment_fu with great success, but have run into a
requirement that I'd like to solve elegantly -- but I've outstripped my
ruby skills.
I have a class that returns a hash of thumbnail definitions, like so:
class Thumb
def
Frederick Cheung wrote:
Why does only the first object in the collection
have a different object_id, and why does this
difference go away if the empty a.steps is loaded
before b is added? Is it a proxy thing?
Because .first will hit the database and load a fresh copy (if the
collection
JHuizingh wrote:
I'm having an issue with the design of my views that I can't seem to
wrap my head around. I have a page where I am showing a collection of
objects in a list. The way that I designed it, it looked something
like this:
main view:
h2here is the list/h2
ul
%=
Ben Johnson wrote:
If I specify a layout in a controller:
class MyController ApplicationController
layout some_layout
end
Any JS request will use the some_layout. I thought certain requests
types were exempt from layouts? When I remove the layout call everything
works perfect, the
Madhankumar Nagaraj wrote:
hi,
i have used backgroundrb to update the database with the files having
some useful data, where i am getting files periodically uploaded.
it works well, but suddenly it stops the worker and stopped the
updation.
when i checked the backgroundrb.log file
it shows
Matt Darby wrote:
Those first three fields are not enclosed in a cell.
That may cause IE to send the parameters in the wrong order.
Please log and post the raw_post string.
Ahh, IE, my old friend. Perhaps this is why I wasn't able to recreate
it.
Well, I can't blame IE for tripping up on
DAZ wrote:
I guess that keeping the ancestors as a string in the database makes
more sense than I first thought. It is interesting that Robert refers
to this as 'caching' the family-tree, which obviously it is, but I've
not really thought of caching information like this (ie database level
Mark Reginald James wrote:
os = sanitize(/#{old_name}/)
ns = sanitize(/#{new_name}/)
Whoops, you'd need to add the prefix /path/to on these
to ensure you only replace the name in the correct context.
Person.update_all key = replace(key, #{os}, #{ns}),
['key like ?', /path
Matt Darby wrote:
tr class='entry'
input id=time_cards__time_card_date name=time_cards[]
[time_card_date] type=hidden value=2008-12-28 /
input id=time_cards__user_id name=time_cards[][user_id]
type=hidden value=121 /
input id=time_cards__id name=time_cards[][id] type=hidden /
td
DAZ wrote:
On Dec 28, 8:07 pm, Mark Reginald James m...@bigpond.net.au wrote:
One alternative is to make the ancestor array a string key
to each record (abe|homer|bart), allowing instant retrieval.
This seems like a relatively good idea, could have a string-key called
family_tree
Scott Kulik wrote:
say for example i had something simple like this in a view:
tr class=eventd%= check_box_tag(:task) %/td
how would i add onclick to change the row color on a check and when the
check is removed?
maybe something like this?
page[task].addClassName('complete')
i'm
DAZ wrote:
I have a family-tree structure to a person model.
I want to be able to find people by specifying an array that
corresponds to the family tree. So if Abe is grandpa, homer is dad and
bart is the son, bart's array would be
To find bart, I can't just use find_by_name(bart) as
Richard Schneeman wrote:
Using rails 2.1.0 I have a really nasty bit of code in my controller in
my create action that i would like to move to my model:
params[:phrase][word] = params[:phrase][word].strip.squeeze( )
if params[:phrase][word] != nil
params[:phrase][second_word] =
suman gurung wrote:
I was trying to install these in_place_editing and acts_as_textiled
plugins in my rails application version 2.2.2, running on windows XP
but i came across some problems when doing so.
...
Has the plugins been moved to a different directory?? i believe these
are fairly
jeroen wrote:
Does anyone know if there's a callback that gets called when a
existing record gets updated but not when a record gets destroyed?
After_update and before_update seem to also get called on destroy. I
there is no such a callback can anybody suggest an alternative way of
Marnen Laibow-Koser wrote:
Thanks for the suggestion. I tried the same test, and got interesting
if disheartening results. When I had recipe[ingredient_lines][]
[ingredient][name] as the only form field, I got the same results as
you. But the moment I added
Greg Hauptmann wrote:
Hi,
What's a good approach for referencing lookup/reference data (static)
that one has loaded in a reference table. Say for example tax codes,
which pretty much have just the database ID and then a description
field. Some options that come to mind:
1 - By ID -
Marnen Laibow-Koser wrote:
On Dec 21, 11:42 am, Mark Reginald James m...@bigpond.net.au wrote:
Marnen Laibow-Koser wrote:
It can't handle more that one level below an array parameter.
Are you sure? I've seen a few examples on the Web which imply that
this should work.
I can confirm
Marnen Laibow-Koser wrote:
input id=recipe_ingredient_lines__ingredient_name name=recipe
[ingredient_lines][][ingredient][name] size=30 type=text /
So far so good. But here's the problem: *submissions don't work quite
properly*. When I fill out the form and submit it, I get params
Dan Weaver wrote:
Hi,
I'm trying to put a css class on a dropdown box built using a select
helper (to make it wider) but I can't get it to take. I thought for
sure, and from what I've seen elsewhere, this code should work:
%= f.select :month, 1..12, :selected = Time.now.month.to_i,
Newone One wrote:
hi new to rails ...
wat does it means...
uninitialized constant BooksController::Books
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:102:in
`const_missing'
app/controllers/books_controller.rb:5:in `index'
Most likely you have written
dschruth wrote:
I'm working on a two-to-many relationship that works fine from the
child object's perspective but not from the parent's.The
imperfect, yet functional code looks like this:
---
class PrimaryTable
Kaushik katari wrote:
Hi,
I have a file called dbcon.rb that I put in the config directory.
I want to call it from rake, and I was using
require 'config/dbcon.rb'
This was allowing me to access the classes in this file.
Somehow, the require command cannot find this file anymore. Is
James Byrne wrote:
Rails 2.2.2
Ruby 1.8.6
ActiveRecord Session Store enabled
For testing purposes I wish to ensure that no session exists. To
accomplish this I wrote:
session.delete if session
But this fails if session == nil and I suspect that it does not work as
I anticipate
Kazim Zaidi wrote:
If Product and Category models are in a habtm relationship, i.e.
class Product ActiveRecord::Base
has_and_belongs_to_many :categories
end
class Category ActiveRecord::Base
has_and_belongs_to_many :products
end
I want a piece of code to be executed every time
lunaclaire wrote:
Thanks for the reply, Mark.
One of the assertions in that RailsWay posting was that by using the
has_many approach, I'd gain efficiency because of caching. I don't
understand enough about caching yet to see why, but let me ask this
about using your approach... would the
Erwin wrote:
I would like to get in a variable the ip address of the host where my
app is running, to change some parameters if it's running locally or
remotely .. is it possible ?
You can try
require 'socket'
REAL_PRODUCTION = Socket.gethostname == 'mysite.com'
or
hostinfo =
Bharat Ruparel wrote:
Coach.find :all, :select = 'c.id, a.id, a.name',
:joins = 'as c inner join accounts as a on a.id =
c.account_id',
:order = 'a.name'
It is only returning the following in irb:
[#Coach id: 99]
That is, it fails to return the account.id (or
Luca Roma wrote:
I have wrote this:
EventDate.find(:all,
:include = [:container,{:event =
[:photo,:event_type_names]},{:place=:location}],
:joins = RIGHT JOIN (SELECT
event_dates.id,date_add(event_dates.date, INTERVAL i DAY ) AS date
FROM (select 0 as i union
If you use MySQL, the field function allows you
to retrieve records in a specific id order:
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/158dc2d879b2fb1/af78ce75ddfa1ed1
--
Rails Wheels - Find Plugins, List Sell Plugins - http://railswheels.com
Leximo wrote:
Taking a look at this, I can see that the votes not being created on
the production server. Maybe something is wrong with MySQL??
It's normal not to see database activity in production log.
Perhaps you should use create! rather than create to ensure
that there are no problems
Pentti Laitinen wrote:
I have a question about using local variables as values for ruby hashes.
I have to do a script that will gather meta data of video files in a
fixed directory and store them in an array of hashes. The problem is
that when I have collected the meta data to a hash called
jamie wrote:
I have a need for a layer of access control when performing a query on
the ferret index. The solution is to add an dditional clause (e.g. -
access_teams:12 OR 13 OR 14 OR 22 OR 1). In order for this to work, I
need exact matching. This query does not perform an exact match. It
Richard Schneeman wrote:
I have a phrase model, a definition model, and a children model
a phrase has many definitions, a definition has many children
currently when i am doing a find i have an include that looks like
Phrase.find(:all,:include = [{:definitions = :children}] , :conditions
David wrote:
I am using rjs to perform ajax deletes on objects within an array
@instructions. The objects within the array @instructions vary
depending on some other logic in my controller and is not dependent on
direct correlations within the database. In other words, when I
update the
[EMAIL PROTECTED] wrote:
What might happen in multithreaded mode??
Any dynamic change to the conditions of an association
would be common to all Rails handlers associated with that
process. Prior to Rails 2.2, this is was always one, so
there was no problem. But if you use Rails in
Void wrote:
We have a secure application on the Internet that you have to log into
to use. We want to be able to display a video from a streaming media
server via this application. The streaming media server is behind a
firewall so I want my Rails app to proxy the stream to the user so
[EMAIL PROTECTED] wrote:
Hi,
I ve defined the following relation in one of my models with a dynamic
where condition:
has_one :selection,
:foreign_key = 'object_id',
:conditions = 'selection_type = 1 and account_id = #
{self.send(:account_id)}'
That works perfect,
Hubert £êpicki wrote:
Does anyone know how can I execute some bit of code after transaction
wrapping up activerecord update/save methods completed?
after_update and after_save filters are both wrapped into the same
transaction, and I need to make external service (druby) aware of
changes
morgler wrote:
I have a problem with observe_form:
%= observe_form( search_form,
:frequency = 0.25,
:update = search,
:loading = Element.show('spinner'),
:complete = Element.hide('spinner'),
:url =
Corey Murphy wrote:
Using the following simple form with a select box, the observe_field is
throwing a javascript error related to the getValue() method in the
prototype library. Any ideas as to why? Everything that I can tell is
well formed syntactically. I'm running Rails 2.1.0.
%
Michael Kahle wrote:
Correct. When you say, Here you've already checked that both the
records are valid..., you must be referencing the way you coded it. I
don't think I'm checking it any time before I run the update.bla.bla!
method. See my other post. I think I do not understand when
Michael Kahle wrote:
Super! Thanks so much. It worked perfectly. The only thing I changed
from your example was to handle the update as a transaction. Updating
@registration and @customer with the .attributes method did the trick
perfectly. I am off to experiment with the
Michael Kahle wrote:
I hope I'm explaining this correctly. Be gentle. Noob here. :)
Ideas on how to solve this? Kind of a chicken or the egg scenario.
Check out this update function in my controller:
def update
@snowplow_registration = SnowplowRegistration.find(params[:id])
Michael Kahle wrote:
did-in-fact keep this a transactional operation. Here is the code I am
using now:
def update
@snowplow_registration = SnowplowRegistration.find(params[:id])
@customer = @snowplow_registration.customer
@snowplow_registration.attributes =
Michael Kahle wrote:
Ooo. Another thought. I noticed that you are doing a transaction
without using the rescue catch. If something else goes wrong, besides
validation, you will never know what happened! :)
Unless you have a pre-save model callback preventing the save for
a specific
Michael Kahle wrote:
Mark Reginald James wrote:
Michael Kahle wrote:
Ooo. Another thought. I noticed that you are doing a transaction
without using the rescue catch. If something else goes wrong, besides
validation, you will never know what happened! :)
Unless you have a pre-save
Michael Kahle wrote:
Ok. I'm confused. If I step through my code line by line it would seem
to me that it does the following:
1.) Creates a new object to dump stuff into.
2.) Dumps everything from the form (params) into these new objects.
3.) Begins the transaction.
4.) First updates
Java wrote:
Yeah, I can confirm that.
I moved the
Price.find_all_by_sessiontype(sessiontype)
out of the helper method and now everything seems to work.
I still think this error shouldn't have happened in the first place.
I tried to investigate, but the dependency loader is so
full
Java wrote:
Hi,
I'm getting an error I just can't find any cause for.
The error is A copy of ApplicationHelper has been removed from the
module tree but is still active! and gets thrown
in a Template that uses a method defined in my ApplicationHelper. The
error occurs only in development
ara.t.howard wrote:
given a setup like
class Parent
has_many :child_parents
has_many :children, :through = child_parents
end
and assuming i'd like to store the style of relationship on the
child_parents table, for example
create table child_parents(
parent_id
child_id
Selva Raj wrote:
Hi,
I am getting some error which I am clue less. I try to pass more than
one parameter with redirect_to, For example,
My params are...
search = {name=, bus_group=1, region=, unapproved=,
tech_owner=}
And I try to give.
redirect_to params[:search].merge! (:action
shagymoe wrote:
The models actually look like this: (notice the has_one :page)
class Project ActiveRecord::Base
has_many :documents
end
class Document ActiveRecord::Base
has_one :page
belongs_to :project
end
class Page ActiveRecord::Base
belongs_to :document
end
Panda Beer wrote:
Hi. Currently, I had 2 models linked with HABTM association: _Article_
and _Tag_
class Article ActiveRecord::Base
has_and_belongs_to_many :tags
end
class Tag ActiveRecord::Base
has_and_belongs_to_many :articles
end
But I believe I need to ad another model
Shagy Moe wrote:
I've got some code that more or less looks like this:
class Project ActiveRecord::Base
def create_new_document
document = Document.new
document.attributes = { project_id = self.id,
attribute2 = etc...}
if document.save
1 - 100 of 122 matches
Mail list logo