[Rails] Re: set_table_name woes, fragmented domain class

2009-03-18 Thread Mark Reginald James
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

[Rails] Re: Using mysql's 'REPLACE' command in active record

2009-03-18 Thread Mark Reginald James
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

[Rails] Re: conditions on association include, hacky but more or less solved

2009-02-19 Thread Mark Reginald James
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

[Rails] Re: Execute an SQL statement each time DB connection is set up

2009-02-19 Thread Mark Reginald James
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

[Rails] Re: conditions on association include, hacky but more or less solved

2009-02-19 Thread Mark Reginald James
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.

[Rails] Re: config.cache_classes breaks reflect_on_assocation ?

2009-02-19 Thread Mark Reginald James
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

[Rails] Re: How can I retrieve the SQL during each model action?

2009-02-14 Thread Mark Reginald James
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

[Rails] Re: Redirect_to Vs Render_component

2009-02-14 Thread Mark Reginald James
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

[Rails] Re: another collection_select, HABTM, :multiple question

2009-02-13 Thread Mark Reginald James
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

[Rails] Re: Transaction block still sets id on model/new_record to false on rollback

2009-02-13 Thread Mark Reginald James
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

[Rails] Re: How to show error messages in pop up or confirm screen ?

2009-02-13 Thread Mark Reginald James
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

[Rails] Re: page.replace_html and table

2009-02-13 Thread Mark Reginald James
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

[Rails] Re: Rails.root problem

2009-01-30 Thread Mark Reginald James
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

[Rails] Re: eager loading kills the :select clause in ActiveRecord

2009-01-30 Thread Mark Reginald James
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

[Rails] Re: Plugin Module Help

2009-01-28 Thread Mark Reginald James
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

[Rails] Re: Rails runtime

2009-01-28 Thread Mark Reginald James
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

[Rails] Re: ajax search feature works in FF but not IE

2009-01-27 Thread Mark Reginald James
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

[Rails] Re: changing model type

2009-01-27 Thread Mark Reginald James
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)

[Rails] Re: Plugin Module Help

2009-01-27 Thread Mark Reginald James
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

[Rails] Re: Plugin Module Help

2009-01-26 Thread Mark Reginald James
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:

[Rails] Re: Belonging models not saving individually

2009-01-26 Thread Mark Reginald James
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

[Rails] Re: habtm relation and dependent = :destroy

2009-01-26 Thread Mark Reginald James
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.

[Rails] Re: acts_as_enumerated

2009-01-26 Thread Mark Reginald James
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

[Rails] Re: getValue() in a Controller problem, help please.

2009-01-24 Thread Mark Reginald James
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% ... .. .. .. .. %

[Rails] Re: find_by_sql error, any ideas please

2009-01-24 Thread Mark Reginald James
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

[Rails] Re: how make attachment_fu with 2 has_attachment

2009-01-24 Thread Mark Reginald James
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

[Rails] Re: forms and controller scope

2009-01-23 Thread Mark Reginald James
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

[Rails] Re: how make attachment_fu with 2 has_attachment

2009-01-23 Thread Mark Reginald James
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',

[Rails] Re: getValue() in a Controller problem, help please.

2009-01-23 Thread Mark Reginald James
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

[Rails] Re: Recovering Mysql::Error - Must I redo establish_connecti

2009-01-23 Thread Mark Reginald James
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.

[Rails] Re: Runner suddenly fails...

2009-01-23 Thread Mark Reginald James
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 -

[Rails] Re: noob question about development mode

2009-01-21 Thread Mark Reginald James
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 -

[Rails] Re: PostgreSQL specific data types in migrations

2009-01-21 Thread Mark Reginald James
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

[Rails] Re: Runner suddenly fails...

2009-01-21 Thread Mark Reginald James
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

[Rails] Re: Recovering Mysql::Error - Must I redo establish_connection?

2009-01-21 Thread Mark Reginald James
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

[Rails] Re: Quick validation question

2009-01-13 Thread Mark Reginald James
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

[Rails] Re: Easy searching by hierarchical category...

2009-01-13 Thread Mark Reginald James
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

[Rails] Re: gem update problem

2009-01-09 Thread Mark Reginald James
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 --~--~-~--~~~---~--~~

[Rails] Re: Accessing request.host in UserMailer

2009-01-09 Thread Mark Reginald James
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

[Rails] Re: Accessing request.host in UserMailer

2009-01-09 Thread Mark Reginald James
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

[Rails] Re: dynamically generated CSV files

2009-01-09 Thread Mark Reginald James
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

[Rails] Re: dynamically generated CSV files

2009-01-09 Thread Mark Reginald James
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

[Rails] Re: What is wrong with validates_presence_of :my_association ?

2009-01-08 Thread Mark Reginald James
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

[Rails] Re: Update_attributes on multiple models, revert back on error

2009-01-07 Thread Mark Reginald James
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

[Rails] Re: Empty collection returned for model with has_many relationship

2009-01-07 Thread Mark Reginald James
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:

[Rails] Re: attachment_fu, deferred thumbnail li

2009-01-07 Thread Mark Reginald James
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

[Rails] Re: Empty collection returned for model with has_many relationship

2009-01-06 Thread Mark Reginald James
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

[Rails] Re: link_to_remote can't replace specified element?

2009-01-02 Thread Mark Reginald James
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 %=

[Rails] Re: Why are JS requests using layouts?

2009-01-02 Thread Mark Reginald James
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

[Rails] Re: backgroundrb stops suddenly

2009-01-02 Thread Mark Reginald James
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

[Rails] Re: index = nil params jumbled *sometimes*

2008-12-30 Thread Mark Reginald James
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

[Rails] Re: Finding Child Records Efficiently

2008-12-30 Thread Mark Reginald James
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

[Rails] Re: Finding Child Records Efficiently

2008-12-30 Thread Mark Reginald James
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

[Rails] Re: index = nil params jumbled *sometimes*

2008-12-29 Thread Mark Reginald James
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

[Rails] Re: Finding Child Records Efficiently

2008-12-29 Thread Mark Reginald James
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

[Rails] Re: changing row color on checkbox click

2008-12-29 Thread Mark Reginald James
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

[Rails] Re: Finding Child Records Efficiently

2008-12-28 Thread Mark Reginald James
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

[Rails] Re: Best way to automatically format model entries

2008-12-28 Thread Mark Reginald James
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] =

[Rails] Re: ror plugins - in_place_editing and acts_as-textiled - install error

2008-12-22 Thread Mark Reginald James
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

[Rails] Re: Callback on update but not on destroy

2008-12-22 Thread Mark Reginald James
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

[Rails] Re: Help with nested models and fields_for

2008-12-22 Thread Mark Reginald James
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

[Rails] Re: how to reference lookup data in DB table - by ID? (or should the ID not be relied upon)

2008-12-21 Thread Mark Reginald James
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 -

[Rails] Re: Help with nested models and fields_for

2008-12-21 Thread Mark Reginald James
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

[Rails] Re: Help with nested models and fields_for

2008-12-20 Thread Mark Reginald James
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

[Rails] Re: Setting a CSS class on select helper

2008-12-19 Thread Mark Reginald James
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,

[Rails] Re: uninitialized constant BooksController::Books

2008-12-19 Thread Mark Reginald James
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

[Rails] Re: one association from two

2008-12-17 Thread Mark Reginald James
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

[Rails] Re: require file in rails

2008-12-17 Thread Mark Reginald James
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

[Rails] Re: conditional delete of a session

2008-12-17 Thread Mark Reginald James
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

[Rails] Re: Callback when objects connect as a habtm relationship

2008-12-17 Thread Mark Reginald James
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

[Rails] Re: how to do special queries ala The Rails Way on associated conditions?

2008-12-17 Thread Mark Reginald James
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

[Rails] Re: how do I get the host or Ip address where my rails app is running

2008-12-11 Thread Mark Reginald James
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 =

[Rails] Re: Active Record - find - select option

2008-12-11 Thread Mark Reginald James
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

[Rails] Re: find with add of an atttributes

2008-12-09 Thread Mark Reginald James
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

[Rails] Re: Get a collection using an array of ids, keeping the order

2008-12-04 Thread Mark Reginald James
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

[Rails] Re: Need Help: Deployment Issues with Voting App?

2008-12-03 Thread Mark Reginald James
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

[Rails] Re: local variables with hashes

2008-11-29 Thread Mark Reginald James
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

[Rails] Re: ferret question - need help with syntax for exact matching

2008-11-29 Thread Mark Reginald James
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

[Rails] Re: eager loading optimization

2008-11-15 Thread Mark Reginald James
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

[Rails] Re: caching for rjs?

2008-11-14 Thread Mark Reginald James
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

[Rails] Re: dynamic condition for has_one and eager loading issue

2008-11-14 Thread Mark Reginald James
[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

[Rails] Re: How to proxy streaming video

2008-11-14 Thread Mark Reginald James
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

[Rails] Re: dynamic condition for has_one and eager loading issue

2008-11-12 Thread Mark Reginald James
[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,

[Rails] Re: AcriveRecord (2.2.0) after_update callback and database transaction

2008-11-10 Thread Mark Reginald James
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

[Rails] Re: observe_form should only react to changes in the form

2008-11-10 Thread Mark Reginald James
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 =

[Rails] Re: observe_field with select throwing javascript error

2008-11-05 Thread Mark Reginald James
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. %

[Rails] Re: Returning changed fields when transaction fails...

2008-11-04 Thread Mark Reginald James
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

[Rails] Re: Returning changed fields when transaction fails...

2008-11-02 Thread Mark Reginald James
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

[Rails] Re: Returning changed fields when transaction fails...

2008-11-02 Thread Mark Reginald James
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])

[Rails] Re: Returning changed fields when transaction fails...

2008-11-02 Thread Mark Reginald James
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 =

[Rails] Re: Returning changed fields when transaction fails...

2008-11-02 Thread Mark Reginald James
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

[Rails] Re: Returning changed fields when transaction fails...

2008-11-02 Thread Mark Reginald James
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

[Rails] Re: Returning changed fields when transaction fails...

2008-11-02 Thread Mark Reginald James
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

[Rails] Re: Strange dependency error after going Ruby1.8.6, Rails 2.1.0 - Ruby1.8.7, Rails 2.1.2

2008-11-01 Thread Mark Reginald James
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

[Rails] Re: Strange dependency error after going Ruby1.8.6, Rails 2.1.0 - Ruby1.8.7, Rails 2.1.2

2008-10-31 Thread Mark Reginald James
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

[Rails] Re: attributes on join model

2008-10-29 Thread Mark Reginald James
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

[Rails] Re: Passing more than one parameters to redirect_to

2008-10-24 Thread Mark Reginald James
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

[Rails] Re: Strange saving problem

2008-10-24 Thread Mark Reginald James
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

[Rails] Re: HABTM on 3 tables

2008-10-24 Thread Mark Reginald James
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

[Rails] Re: Strange saving problem

2008-10-23 Thread Mark Reginald James
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   2   >