I have a order object, which have a create method like this :
def create
@order = Order.new(params[:order])
# @order.status_id = "1"
respond_to do |format|
if @order.save
flash[:notice] = 'Order was successfully created.'
format.html { redirect_to(@order) }
...
Given the following models:
class Room < ActiveRecord::Base
has_many :contracts
end
class Contracts < ActiveRecord::Base
# columns
# start_date Date
# end_date Date
belongs_to :room
end
The contracts of one room are not overlapping. My question is, how i am be able to find gaps between contracts. An Example:
room = Room...
Hi all,
I am quite new to Ruby on Rails and what to make sure I set of on the right foot. I want to do some simple "Live Calculations" and am not sure of the best method.
If we use the cookbook example.
Each Recipe has many ingredients.
Each ingredient has a description, qty, cost and a total.
What I want to do is the following;
1) i...
So that's the problem. In my application globalize2 returns a NIL string if there's no translation on some record, instead of falling back to default_locale. I wonder how to enable thin functionality? Does anyone figured that out?
...
I have a Virtual Dedicated Server that I use to host small websites that aren't large enough to justify their own dedicated slice. I am a Rails developer and am currently using an Ubuntu/Nginx/Mongrel Cluster/SQLite stack to deploy these applications.
I feel that the memory being consumed by each Mongrel instance is too high. I am won...
I am relatively new to programming but have some experience with Ruby on Rails and I would like to know if there is an open source template in RoR that I can modify to set up an on-line questionnaire for a charity. It should be able to to collect answers for multiple answer question and yes/no questions, and a some sort of skipping logic...
I'm trying to test a plugin that i wrote by running:
rake spec:plugins
When i execute this command it appears that it drops my database tables (in my test DB) and then runs a migration without any plugins loaded to give me a clean database. This would normally be fine, but I am using a plugin that allows me to set index length limits ...
I have a simple form that takes some fields and adds them to the database. Underneath the form is a html table which displays all the products currently in the DB.
Controller: pages , action: product
#@product is for form capture
#@prods is for displaying list of all products
def product
@product = Product.new(params[:page])
respond...
Edit: To be clear, I'm trying to use this kind of generator (i.e. with a 'yield' statement) not a Rails generator.
I have the following (simplified) initializer mixin in a Rails project that I could use some help with. What I wanted to do was create a generator to track Twitter API calls (this is just for debugging, I know about rate_li...
is possible to use ruby 1.9 with rails 2.3?
thanks
...
Hi all,
I have some issues in Rails Active Record Inheritance, I need to create a model that inherits parents class properties(fields) and should also hold its own properties.
Ex:
Parent Class
class Content < ActiveRecord::Base
end
Classes inheriting parent class (Content)
class Wiki < Content // Inherting Class Content
end
clas...
I'm creating a shopping cart based on the one in Agile Web Development With Rails (version 3). I have it set up where "items" are added to a "cart", then upon starting the checkout process, they are added to an "order" object as "line_items". "line_items" represent one "item" in any quantity. Up to this point, I'm not deviating from the ...
I am generating some json to send to a web service.
Currently I am creating a hash, loading it with the data and then calling to_json to generate the json string to send.
But I figure it would be much cleaner and more rails like if I could use a template in a .erb file to generate the json for me.
All the info I can find on erb files ...
I just can't seem to find where the error is or correct it. Everything works well on my Windows env but it's giving me this problem on the linux env.
Perhaps it has to do with the different versions but they are the same, 0.9.4 yet I have constantly detected some anomaly when you install Spree in linux. If you type in "gem list" you d...
I'm using ruby on rails 2.3.2, and I've got a list with checkboxes. So I created a remote_form_for to handle multiple submit buttons. Those operations work great, and so the pagination. The problem raises when I both submit the form and then try to paginate. I get the following error instead of displaying next page, as expected.
try {
E...
I have the following (simplified) class hierarchy:
def Parent < ActiveRecord::Base end
def Child < Parent
belongs_to :other
end
def Other < ActiveRecord::Base end
I want to get all Parent objects and -if they are Child objects- have them eager load the :other association. So I had hoped I could do:
Parent.find(:all, :include => [:o...
How I can download a remote image (http protocol, the url is in the image_remote_url attribute) and save it as an attachment to S3 via Paperclip ?
class Product < ActiveRecord::Base
require 'open-uri'
attr_accessor :image_remote_url
has_attached_file :photo,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml"...
I wanted to have custom error messages for my field names. I stumbled upon another SO question
So I added something like this:
class Product < ActiveRecord::Base
validate do |prod|
prod.errors.add_to_base("Product price can't be blank") if prod.prod_price.blank?
end
end
But I also want to check the numericality of prod_price...
As far as I know both rails:freeze:gems and rake gems:unpack are placing the gems to /vendor. rails:freeze:gems places them to /vendor/rails, gems:unpack place them to /vendor/gems. The point for me seems to be the same, however. In both cases the goal is to fix the gems and their versions as they were during the development. Is there an...
I am trying to do the following in a Ruby on Rails project:
class FoodItem < ActiveRecord::Base
has_and_belongs_to_many :food_categories
has_many :places, :through => :food_categories
end
class FoodCategory < ActiveRecord::Base
has_and_belongs_to_many :food_items
belongs_to :place
end
class Place < ActiveRecord::Base
has_m...