In order to override the table_exists? method in the Rails PostgreSQL adapter I have tried the following in an initializer file:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
def table_exists?(name)
raise 'got here'
end
end
This will raise the the following error:
uninitialized constant ActiveRecord::Conne...
My desired behavior is that when destroy is called on an instance, that instance will not actually be destroyed, but it will just be marked as having been destroyed. This needs to percolate up for any model associations.
In the models that I don't want to actually destroy, but just mark them as deleted I have a deactivated field.
From...
I am not sure how to title this question, its something rather weird.
Well, here is the thing, I've created a model called UserProfiles for which the migration file looks like this:
class CreateUserProfiles < ActiveRecord::Migration
def self.up
create_table :user_profiles, :primary_key => :id, :options => "auto_increment = 1" d...
Hello!
I have a photo_album
which has several photos, IDs: 4,9,10,11,31 -- all for photo_album:3
I have the following for my DEF SHOW in my Photos controller:
@photo = @photoalbum.photos.order("created_at ASC").paginate :page => params[:page], :per_page => 1
Problem is, if the URL is: /photo_albums/3/photos/10 The code above starts ...
In Rails 2 I know of a few plugins for enumerations such as acts_as_enumeration and enumerate_by but they don't seem to be maintained or updated for Rails 3. Preferably, the solution would store the enum in memory rather than a database for performance reasons but really any method would be useful since it can always be cached.
I did fi...
There are a few very good authorization gems, like cancan and declarative_authorization. But here's a problem: authorization rules are seperated in class, but i need to place them in table or maybe some yaml config file to change them in admin panel eventually. Perfectly, if i can either change permissons for user groups and for individu...
first i use
rails g scaffold product name:string
the generate crud page works fine
but i also want to an control module so i use
rails g scaffold_controller admin/product name:string
i want to put manager code in a admin directory,but this generate crud code can't work,i need modify the generate template code,is this a rail3 issu...
Hi there,
I have a rake task that I created to populate my database with fake data. One of my models has a before_validation callback method which uses the blank? method. When I run my rake task, the task is aborted with the following message:
rake aborted!
undefined method `blank' for #<BigDecimal:101848c10,'0.35E2',9(18)>
...
I have a rather misterious problem dealing with booleans in Rails, here is how to reproduce:
rails new boolean_bug
rails generate model User verified:boolean
With this you should have an empty project with the User model.
3 Inside boolean_bug/app/models/user.rb
'
class User < ActiveRecord::Base
before_save :set_false
attr_access...
i use
rails g scaffold_controller admin/sub/Product name:string
to generate crud page,
now i need write route.rb file to map the admin_sub_product_controller,how to write this route file on rails3?
it's hard for me to write 2 level namespace mapping route
namespace admin do
resource :products
end
this only wokrs for /admin/pr...
I have the following models with associations as given below:-
class Comment < ActiveRecord::Base
belongs_to :post
belongs_to :user
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable,...
I was previously using Ruby 1.8.7 & Rails 2.3.5 on Heroku.
I upgraded my development environment to Ruby 1.9.2 and Rails 3.0.1 using the instructions this railscast. RVM is used, so the system versions of Ruby and Rails are still 1.8.7 & Rails 2.3.5 respectively, but I have an RVM environment with 1.9.2 and 3.0.1, which I now use.
I'm...
I have a controller which has a lot of options being sent to it via a form and I'm wondering how best to separate them out as they are not all being used simultaneously. Ie sometimes no, tags, sometimes no price specified. For prices I have a default price set so I can work around with it always being there, but the tags either need to...
Here are my smtp settings for Google Apps in setup_mail.rb.
:address => "smtp.gmail.com",
:port => 587,
:domain => 'mysite.co',
:user_name => '[email protected]',
:password => 'password',
:authentication => 'plain', ...
I'm using this code (taken from here) in ApplicationController to detect iPhone, iPod Touch and iPad requests:
before_filter :detect_mobile_request, :detect_tablet_request
protected
def detect_mobile_request
request.format = :mobile if mobile_request?
end
def mobile_request?
#request.subdomains.first == 'm'
request.user_agent ...
Dear all.
I'm using heroku to deploy my app (rails 3). Ok so I do the usual, which is a git commit, a git push heroku master => deployment is ok, gems are installed, etc...
When running my app in the web browser, I get an heroku error : app crashed.
In the ouput of heroku logs, this got my attention :
==> dyno-2625316.log (crash) <==
...
Hi all
I have a model containing products. I would like to create a search form to allow users to apply compound filters to products as required. For example:
Products with a price of between '10' (text field) and '50' (text field) with a colour of 'Red', 'Green' or 'Blue' (check box fields) and a weight of 'Less than' (select field) ...
I'm trying to make my project OSS, and I'd like to remove any sensitive info from the configs. I'm trying to have ENV['DB_PASS'] = mypassword. Where would I set this? I've tried export DB_PASS=mypassword in my .bashrc file. But that's not working.
...
I've understood that blue dashes in features output means the step was skipped because something before it failed but in all of my scenario outlines I get blue dashes but also a line that says all passed.
Here is my Scenario Outline.
Scenario Outline: Attempt to assign a role when not authorized
Given a <user_who_can_not_assign_roles...
Before I roll my own I'm just curious if there are any other solutions similar to heroku's docs (sinatra) or the rails guides template for making a simple faq page for a rails app. I like heroku's on sinatra and have been currently using just a simple pages controller with markdown, but i'm looking for maybe something even better suited...