search for: ivanvega

Displaying 14 results from an estimated 14 matches for "ivanvega".

2006 Jan 04
2
Creating a model that acts as a settings manager
Hi, I was wondering how could you create a model that is tied to all the records in one table, and retrieves the values of all records on first load, and also handles the updating of its values. For example, suppose I have this table: id INT(11) PK group CHAR(40) name CHAR(40) value CHAR(128) updated_at DATETIME Sample rows: group name value --------------------------- main something
2005 Dec 23
6
Stories with many tags, tags with many stories, has_and_belongs_to_many howto?
Hi, I began experimenting with habtm relationships, and so I created a stories table, a tags table, and a stories_tags table referencing the former 2. When I create a "story", I want to add several tags to it. Then, the model should create those tags and link them to the respective stories, and for the tags that already exists, just link them to the story. I tried something like
2006 Jan 06
4
"Selecting" a calculated row / Using :select in the paginate method
Hi, I was trying to use the :select parameter to select a calculated row, but it appears that the parameter is not picked up by the paginate method. I want to add the following to the select statement: timediff(now(), created_on) as age So I tried: @story_pages, @stories = paginate :stories, {:per_page => 10, :include => ''user'', :select =>
2006 Feb 23
5
Help with SCGI please :(
Hi, While learning Ruby and Rails, I decided I just as well learn Linux along the way... It''s been fun, but I''m stuck at one of those exasperating moments... I hope someone can help me :) I installed Ruby 1.8.4 on Fedora Core 4, then Rails, then lighty, and then SCGI. I used yum to install lighty... and it already comes with mod_scgi. I created my first application in
2006 Apr 21
1
Using fixtures inside migrations
Hi, I want to add data from a fixture file to a table inside a migration. I''ve saved the file in db/migrate/fixtures/countries.yml I guess I could just open the file, read the entries, and add them to the database using AR, but I''m hoping I can use Rails for all that. Also, if I have a file, say, with 200,000+ records, what would be the best method (performance-wise) to go
2005 Dec 16
3
Using :include "recursively" (including the children of the child)?
Hi, Let''s say I have the following hierarchy of tables: Group <- parent Location <- child of Group School <- child of Location Phone <- child of School Then, if I want to do this: Location.find(...someparms..., :include => [:schools, :group, :phones]) I get an association error (Association was not found). I guess it happens because AR is looking in the Location model
2006 Jan 06
6
RoR API Firefox search plugin
Hi, Lately I''ve been visiting the RoR API site quite often, so I modified a Firefox search plugin to make searches to it (with Google). So here I post it in case someone finds it useful: <SEARCH version = "7.1" name="Google - RoR API" description="RoR API SiteSearch" method="GET"
2006 Jul 27
0
Using CRUD + non-standard URLs
Hi, Please take a look at this code: map.with_options :controller => ''school'' do |m| m.school_show ''e/:id'', :action => ''show'' end map.resources :school map.connect '':controller/:action/:id'' And then I want a school to be shown on URLs like /e/123 and show a creation form on /school/new and have
2006 Mar 08
0
How to add something similar to :counter_cache - :avg_cache
Hi, I was thinking of doing this with a stored procedure, but I thought it could be better implemented in Rails. I have several tables that hold a counter cache for other tables, which aren''t directly related. For example: Table ''schools'' has records that belong_to table ''counties'', and that table has records that belong_to table
2006 Mar 11
0
Using :joins - How to help Rails populate a list of records from a complex join
Hi, Due to some performance issues, I want to use a custom query for a find method: def find_in_state(state) State.find :all, :limit => 10, :conditions => [''s.id = ? AND '' + ''s.id = c.state_id AND c.state_id = ? AND '' + ''c.id = col.county_id AND
2006 Jan 22
2
Using register_template_handler to serve CSS files (Making ActionView handle .css as .rhtml)
Hi, I wanted to be able to use some Rails code inside CSS files, so I set up a controller (StylesController) to serve CSS files that reside inside the controller''s view folder when the browser requests /stylesheets/:action So in the controller I just define empty actions with the names I want my style sheets in (ie: def cooleffects end - that would respond to
2006 Jan 06
3
Single table inheritance - HowTo?
Hi, As per another member''s suggestion, I''m trying to user STI. So I have this table: CREATE TABLE `settings` ( `id` int(11) unsigned NOT NULL auto_increment, `type` char(40) NOT NULL default ''General'', `name` char(40) NOT NULL default '''', `value` char(128) NOT NULL default '''', `updated_on` datetime default NULL,
2005 Nov 15
3
Defining a variable in the environment and using it in controllers and views
Hi, I wanted to define a global variable in environment.rb like this: @pagemeta = {:title => ''Default page title'', :description => ''Default page description'', :keywords => ''Default page keywords''} And then, in a controller, override one or several of its values (like @pagemeta[:title] =
2006 Feb 23
5
Running apps in subdirectories using lighty/scgi
Hi, So thanks to Zed I was able to get lighty/scgi and a Rails app running. I know this might not be the best place to post this, but I guessed there may be several others with similar experiences here. So, the following step is to have several apps each in its on subdirectory. I tried the following to no avail: $HTTP["url"] =~ "^/tango/" { server.document-root =