I have a model (Query) which I use to, of all things, query the database. This is to enable raw SQL access. I want to ensure that db access using this model is read-only. Short of checking the sql query for ''insert'' and ''drop'' and ''update'', is there a more rails-like way of doing this in my app/models/query.rb itself? Thanks in advance, cal
On 2/10/06, cal <charles@lesburg.com> wrote:> I have a model (Query) which I use to, of all things, query the database. This > is to enable raw SQL access. I want to ensure that db access using this model > is read-only. Short of checking the sql query for ''insert'' and ''drop'' and > ''update'', is there a more rails-like way of doing this in my app/models/query.rb > itself?You could have it use a separate database connection that logs in as a user with read-only access in your database.
How can we use seperate db connection since there''s only 1 account per environment? Does anyone already try this? -- Tirta K. Untario On 2/11/06, James Ludlow <jamesludlow@gmail.com> wrote:> On 2/10/06, cal <charles@lesburg.com> wrote: > > I have a model (Query) which I use to, of all things, query the database. This > > is to enable raw SQL access. I want to ensure that db access using this model > > is read-only. Short of checking the sql query for ''insert'' and ''drop'' and > > ''update'', is there a more rails-like way of doing this in my app/models/query.rb > > itself? > > You could have it use a separate database connection that logs in as a > user with read-only access in your database. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Models can be set to readonly. View the docs. Bob Silva http://www.railtie.net/> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org [mailto:rails- > bounces@lists.rubyonrails.org] On Behalf Of Tirta K. Untario > Sent: Sunday, February 12, 2006 10:22 PM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] read-only access to database? > > How can we use seperate db connection since there''s only 1 account per > environment? Does anyone already try this? > > -- > Tirta K. Untario > > On 2/11/06, James Ludlow <jamesludlow@gmail.com> wrote: > > On 2/10/06, cal <charles@lesburg.com> wrote: > > > I have a model (Query) which I use to, of all things, query the > database. This > > > is to enable raw SQL access. I want to ensure that db access using > this model > > > is read-only. Short of checking the sql query for ''insert'' and ''drop'' > and > > > ''update'', is there a more rails-like way of doing this in my > app/models/query.rb > > > itself? > > > > You could have it use a separate database connection that logs in as a > > user with read-only access in your database. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Reasonably Related Threads
- models and validation problem
- Error: Before updating scaffolding from new DB schema, try creating a table for your model (Product)
- Rails development on Mac OS X 10.4 Intel
- How painful is the 1.0 -> 1.1 upgrade going to be?
- Can I send rendered .html to somewhere besides the web server?