similar to: Use DB view to back model class?

Displaying 20 results from an estimated 200000 matches similar to: "Use DB view to back model class?"

2006 Aug 10
3
Want to use a view helper (TextHelper) in a model class
I have a model that deals with HTML and I want to use the text_helper.sanitize method to strip the HTML of Javascript. However, it doesn''t appear that I can get easy access to the text_helper methods from within a model. Anyone have any suggestions for how to do this? In general, I think that there are some ActionView helpers which are generic enough to want to use in a model class.
2006 Aug 16
0
Parse Rails routes in a text in a DB?
Hi all Is there a way to parse routes of Rails within a text in a DB? E.g. "This is some very great text in a database! You can edit it here: <%= my_route_url :action => ''edit'', :id => 123 %>!" Thanks for infos. Josh -- Posted via http://www.ruby-forum.com/.
2005 Nov 28
1
Getting a model to connect to a different DB
Hi guys, I''m still finding my feet in rails and I would be really grateful if you could help me with this problem: I need to use 2 databases for my application; one for user details and one for everything else. So basically what I think I need to do is set the database to the general one as default and then tell the User model specifically to connect to the user DB. I have added an
2006 Mar 28
1
Rails noob db questions
Hi, I''m trying to get my head around rails, but the documentation seems sparse at best (and manuals.rubyonrails.com is unreachable from my location for whatever reason). I''m trying to figure out a few things: 1) The documentation for the magicfields mentions using datetimes instead of timestamps, which pgsql doesn''t appear to support. What''s the answer in this
2005 Dec 17
1
Adding model attribute without db field
I need to add an attribute to a model but there is no need to add a corresponding database field. The model is a child of ActiveRecord and it corresponds to a table in my DB but when I add it in the usual Ruby way, I get a ''number of redirects exceeded'' error. Here is my code; The model; class Category < ActiveRecord::Base attr :status end The controlller;
2006 Jun 14
3
Attributes for a model which are excluded from DB?
If I want to do this but not save to the database, how can I go about it? things.each do |thing| changed = someotherqueryresult thing.update_attribute :testattrib, changed end Essentially I want to create a collection called things with some extra attributes that are not saved into the database, as they are just used for sorting in a view and should not be saved (in fact saving them wastes
2007 Aug 13
1
Oracle support for rake db:reset
I recently submitted ticket #9240 (1) adding Oracle support for the rake db:reset task. I don''t consider myself an Oracle expert by any means, and would appreciate if someone familiar with the database can take a look and verify that I''m going in the right direction. Thanks. 1. http://dev.rubyonrails.org/ticket/9240 -- Josh Knowles joshknowles@gmail.com
2006 May 10
2
newbie q on displaying a db field value in the view
My layout calls a few links like so: <%= link_to ''| Home '', :controller => ''search'', :action => ''''%> <%= link_to ''| Search '', :controller => ''search'', :action => ''''%> I would also like to display two values from my user table in the same layout right after the
2012 Jul 21
3
Attributes in classes db/migrate or app/models
Hello, I''ve got some experience in Java, and recently, I''ve begun to practice with Rails. One of the things that has surprised to me, after I''ve read some books, it''s that classes hasn''t got attributes; the attributes are in the files db/migrate/*. After that, the ORM makes the mapping with de Database. But the attributes aren''t in the files
2013 May 01
3
PG gem behaves strange. It requires live DB connection to only generate a model. How to turn it off?
I used MySQL as a backend before. Now I had to move to PG since Heroku doesn''t have MySQL and forces everyone to use their Heroku-PG database. But PG virsion of Rails works diffidently. I cannot generate a model without PG server running: >> C:\ruby\Heroku\App>rails generate model Products >> >> C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-
2006 Jun 11
4
[Question} how best to use attribute driven db with Rails
I designed out a mostly attribute driven database. Originally i was going to use PHP, but have now decided to use RoR. Being able to use the built in OR functionality would be nice, but I am not sure how well it melds with attribute dbs. If anyone can give me some pointers, I would really appreciate it (especially since this is my first endeavor and on an important project as well).
2006 Feb 01
0
habtm and counter (xxx_count field in DB)
Hi all I have the following models: class Member < ActiveRecord::Base # DJ Profiles the member is part of has_and_belongs_to_many :disc_jockeys, :join_table => ''members_are_disc_jockeys'', :uniq => true end class DiscJockey < ActiveRecord::Base # Members that are part of this DJ profile
2006 Apr 20
5
Using Migrations to convert join table to join model
Greetings, I''m trying to convert a HABTM w/attributes join table in my database into a join model table in order to utilize the new has_many :through functionality introduced in Rails 1.1. Here''s the current table definition: licenses_user_groups: license_id, user_group_id, usage_notes Perhaps it was a mistake, but I made (license_id, user_group_id) the primary key. Now,
2006 Jun 22
1
finding one db entry and how to display it in a view
Here is my controller: class BrowseController < ApplicationController def index @products = Product.find(:all) end def item @products = Product.find(:all, :conditions => "id = #{params[:id]}") end end --- the ''item'' method is bothering me, because I know I should be able to simply do: def item @product = Product.find(params[:id])
2006 Jul 26
5
code for uploading files to the filesystem instead of db
Does anyone have any standard code for uploading files to the filesystem? I''ve got code already for uploading images to the database but I''d prefer to store the files on the filesystem. In particular I need to know how to (a) ensure a file has been selected in the file_field (b) how to extract the filename from the file_field (c) how to actually move the file from client to
2007 Apr 17
3
using rake db:fixtures:load with rspec fixtures
Hi, I''m new to rspec. I have some fixtures in /spec/fixtures. If they were in /test/fixtures they could be loaded with rake db:fixtures:load. Is there any way other than a symlink to load my rspec fixtures into the database with rake? Or, can I cause rspec to load the fixtures from /test/fixtures? Thanks, Paul
2006 Dec 17
0
I'ts not a (db-)model, not controller - so is it a lib?
Hi! I''m starting a test spike for a small Rails project, that doesn''t have any database backend. It''s a kind of a (Debian Linux) system administration utility like webmin that collects and displays system informations, modifies config files at different locations and runs system tasks like the installation of Debian packages. I''m not sure yet, if Rails is the
2006 Jul 17
6
Best Practices: Splitting the "view model" from AR model
All, I''m starting to see view state information creeping into my model class. For example, I have text fields in my view that need to be set a certain way depending on whether or not a checkbox is checked. And while the values of these text fields ultimately do represent database columns that are related to the backing AR object, the text_field values also represent attributes on a
2006 Jan 16
3
the dreaded "Before updating scaffolding from new DB schema, try creating a table for your model (Blog)" error
Hi Can any one help me with this? I think that this is soemthing quite simple as there is quite abit traffic about this on the web and everyone sems to figure it out. I have tried most of the solutions that I can find. but nothing. I have mysql 5.0.11 working on linux redhat 9. ruby is working rails install mysql library seem to be there. to some trying rt get mysql to install need to
2005 Dec 28
1
Model from DB generator
Hello all, Does a generator exist to generate the ActiveRecord model from the database? I wouldn''t mind if it generated parent-child relations always as has_many - belongs_to. The scenario in my case is a database of about 180 legacy tables, with a pattern that the foreign keys use (<parent table name>_OID). These I''d like to wrap in the model as easily as