Hi,
I want to run a raw SQL query as following:
ActiveRecord::Base.connection.execute(some_query);
Can I capture any errors that happen while executing the query? If yes, how?
Does execute returns anything? It doesn't say in the documentation.
Cheers
...
I'm trying to return an array of counted values for consecutive date ranges (that will vary in distance), so that I have something like the following:
counted_values = [2,0,4,5,6,0,0,4,2]
So far I've written something that works but makes me shudder slightly, as I'm sure there's a more Rubyist/Rails way of doing it.
Current code:
...
So let's say you have
line_items
and line_items belong to a make and a model
a make has many models and line items
a model belongs to a make
For the bare example idea LineItem.new(:make => "Apple", :model => "Mac Book Pro")
When creating a LinteItem you want a text_field box for a make and a model. Makes and models shouldn't exist...
How to place a drop down for the virtual column, in the ruby on rails. The virutal column does not exist in my table , but I want to get the value from the drop down ,when user saves the data.
for example,
product_price is a virtual column , which doesn't exist in my database table. But I would like to have a dropdown, with product pr...
I am new to RoR and still playing with associations. I need to have two references to a particular model in another model. The scaffolded code doesn't work and I get a "uninitialized constant" error.
Generation commands:
script/generate scaffold BaseModel name:string
script/generate scaffold NewModel name:string base1:references base2:...
I have a controller dealing with sending SMS Messages, and it's set up as a default resource. Now, business requirements have changed and we want to offer the user three different ways of sending the message:
To everybody on their contact list
To a segmented portion of their contact list (predefined)
To individual contacts that they c...
I have following code in my deploy.rb
namespace :app do
desc "copies the configuration frile from ~/shared/config/*.yml to ~/config"
task :copy_config_files,:roles => :app do
run "cp -fv #{deploy_to}/shared/config/hoptoad.rb #{release_path}/config/initializers"
run "cp -fv #{deploy_to}/shared/config/app_config.yml #{release_...
Hello,
I have two tables on mysql: users, and management. The users table has a numeric id, and the management table has a varchar foreign key which is the primary key of the other table. The types are not the same, and this seems to be the main problem when I build an index from the User model, and try to include one column from the ma...
Is there a way to justify text in pdf.text_box using the prawn plugin?
...
How do i use a link_to inorder to go to a specific (html) ID on a page normally
if i wanted to go to the "whatever_id" on a page i could use
<a href="http://www.example.com/index/mypage#whatever_id>Click Here</a>
but i would like to use my link_to
<%= link_to "click here" , {:action => "mypage", :controller => "index" }, :id => "...
I am trying to use xml builder without explicit definition of elements. This is useful when the required elements are variant.
How can I accomplish something similar to the following?
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
for col in [:customer, :name, :address, :city, :street, :postal_code]
eval("xml.#{col.to_s....
First of all, according to this answer, the :cache => true option on stylesheet_link_tag and javascript_include_tag doesn't work on Heroku. Is this true? I've found :cache => true to work occasionally, but not always (weird!)
Also, what's the best solution here? Ideally it would seamlessly combine and minify all CSS / JS. Heroku Asset ...
I have Rails app with a Postgres backend.
I need to add full text search which would allow fuzzy searches based on Levenshtein distance or other similar metrics. Add the fact that the lexer/stemmer has to work with non-English words (it would be ok to just switch language-dependent features off when lexing, to not mess with the target l...
Hello,
I'm building some applications using rails.
All apps using restful auth plugin for User base and declarative authorization plugin for authorization rules.
But I need to merge all site's User accounts to one User base for providing login for all sites.
I.e like 37signals working on. Here is their work ;
http://37signals.com/...
I run an instance of a rails application that is developed by another team. Back when I started, the common way to deploy Rails apps was to use Mongrel behind Apache, and that's the configuration that that team used for their own instances. Since I'm a Windows guy, and since both Apache and Mongrel can easily be set up as Windows service...
Given a user model something along the lines of:
class User < ActiveRecord::Base
acts_as_authentic do |config|
config.validate_email_field = true
end
end
I would like to be able to modify "true" to be specific to the user that is signing up. I would like to be able to do something like:
class User < ActiveRecord::Base
ac...
I'm trying to use this technique (http://blog.hasmanythrough.com/2008/4/2/simple-pages) on "boiler-plate" pages I want to keep in a subdirectory of my controller's view folder.
How would I do this? The below doesn't seem to work: returns a "Template missing" error.
Error:
Missing template home/New_York_apartments.erb in view path app...
I'm a seasoned web developer but only have a modicum of Ruby/Rails experience. I just got an interview Monday at a Ruby shop, they do realize I don't have much Ruby experience. Besides 2 or 3 Ruby books I have lying around, what other resources might I avail myself of for a weekend crash course in Ruby. I do have a bare minimum accoun...
Instead of running each rake task individually like this:
rake db:drop
rake db:create
rake db:migrate
rake db:load
I want to run one rake task that does all for.
This is what I have for my rakefile:
desc 'This rebuilds development db'
namespace :rebuild_dev do
Rake::Task["db:drop"].execute
Rake::Task["db:create"].execute
Rake::Ta...
I'm looking for a way to faux-delete rows from a table using Rails. The rows shouldn't show up in any normal .find() search except for when I want to show recently deleted items. I'm using an Activities table right now for management of such tasks, which stores the class, id and method performed on rows recently.
Is there a way to disab...