Displaying 20 results from an estimated 6000 matches similar to: "Creating a model that acts as a settings manager"
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
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
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
2009 Oct 08
6
Eager Loading a Relationship That Has No PK/FK
I''m attempting to wrestle an old DB into Rails.
This relationship is giving me trouble:
class Show < AR::Base
has_many :segments
end
class Segment < AR::Base
belongs_to :show
has_one :media #this has no PK/FK relation
end
A Segment is "linked" to Media by Media.name, which is the result of
concatenating Segment.name and Segment.part. As I said there are is no
2006 Jun 09
3
sqlSave() and rownames=TRUE makes my Rgui crash
Hello,
I created a table in MySQL with this command
CREATE TABLE example (pk INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(pk),
id VARCHAR(30),col1 VARCHAR(30),col2 VARCHAR(30))
### In R, I can connect to this table:
library(DBI)
library(RODBC)
chan <- odbcConnect("MySQL51", uid="root", pwd="xxx")
first <- sqlQuery(chan, "select * from example")
2006 Apr 18
6
Postgresql and ActiveRecords problems
Hi all. I have a problem with postgresql PK columns and ActiveRecord.
The error is: PGError: ERROR: null value in column "item_id" violates
not-null.
Ok, it''s wrong to insert NULL into PK columns, but rails doing it. How
to fix? So sad..
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
2006 May 17
10
HABTM << producing incorrect insert sql ?
Greetings railsers -
I''m trying to add to a collection through HABTM, but the sql
insert is trying to insert a PK rather than letting mysql produce the
auto_increment''ed PK.
## @medication_dose holds a validated, saved model
@medication_dose.medication_frequencies << MedicationFrequency.find
(:all)
The above bails with,
Mysql::Error: #23000Duplicate
2006 Jul 12
1
Dumping schema
All,
It looks like rake db:schema:dump does not dump primary keys.
I have some legacy table that don''t follow the convention ie pk = id
and
none of the primary keys for these tables are getting dumped...
Seems strange as this should be readily available from the db. I am
using
MySQL. Is anybody else seeing that ?
Incidentally how does one specify a primary key using
2006 Aug 02
4
is it possible to duplicate a key? --new
Im not very familiar with RoR so this question might be kind of silly.
I want to store strings from different lenguages in a database. I want
to have the key for the string in english be the ''key'' for all the
corresponding traslations of that string. For example:
(database columns)
lenguage-------------key-----------------value-----
english hello
2005 Jun 16
3
PostgreSQL Scaffold Doesn't Insert PK?
I am new to Rails and Ruby. I''ve been a WebObjects developer for a few years
and before that J2EE (shudder). I wanted to try RoR so I am porting an
existing Web app.
I am running the latest release on Tiger and PG8.
Right now my single table has three attributes:
id | integer | not null
hotel_name | character varying(255) | not null
hotel_location |
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,
2006 Jan 21
7
n-way joins
Hi,
I''m somewhat of a Rails newbie and am trying to understand how to
formulate n-way (3 or 4 way) joins in Rails (where the join tables
contain extra data as well.)
Let me give you my basic entities:
foos
id - pk
name - unique
bars
id - pk
name - unique
bazs
id - pk
name - unique
frozs
id - pk
name - unique
then i have two separate join tables:
foos_bars_bazs - 3 way join
2006 Mar 12
5
AR - Migrations - how to use a varchar as primary key instead of int ?
Hi
I''d like to have a varchar primary key named id instead of the default int
id. Does anyone knows how to specify this from migrations ?
Should I also specify something in the model class ?
thanks!
Thibaut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060312/797bca4b/attachment.html
2011 Aug 29
32
Weird assignment problem, very confused :(
Hey, I have the following line in my controller:
User.create(:email => "fuuu-+RB1Aph5k6s@public.gmane.org", :password =>
''asldfkjadsfadsf'', :ip => request.remote_ip)
my IP is 127.0.0.1 - now User.find_by_ip(''127.0.0.1'') returns 0
records although User.first contains ''127.0.0.1''
if I change it to:
User.create(:email =>
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"
2005 Dec 16
10
''Code table'' best practices?
I''ve been going back and forth about this kind of thing for a while.
I reverse my opinion on it every project, and I''m wondering if anyone
has any advice/battle scars to share. As usual, please forgive my
long-windedness in advance.
Let''s say I have this:
Table: PLANS
ID int
CATEGORY_CODE_ID int
--Other junk removed for clarity
Table: CATEGORY_CODES
ID int
DESCRIPTION
2005 Dec 17
1
lost in an ActiveRecord::StatementInvalid
I have an error I don''t know how to debug. I am adding the login
suport in Depot (the example in the RoR book) and
LoginController#add_user throws ActiveRecord::StatementInvalid in an
innocent /login/add_user GET request.
The trace goes down to a call to SQLiteAdapter#table_structure, and
the source code suggests what''s happening is that "PRAGMA
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 =