I'm trying to count the number of rows in a certain table by datetime.
More specifically, by a certain month, but can't find the right way to
write the conditions for it.
xxx.count(:all, :conditions=> :xxx => yyy)
I have a datetime yyy to compare with xxx, but only want to compare the year and month.
...
I have a controller with the following layout logic
layout 'sessions', :except => :privacy
layout 'static', :only => :privacy
The issue is that Rails seems to ignore the first line of code and the layout "sessions" is not applied for any actions. It simply thinks to render the static layout for privacy and no layout for the rest.
...
I'm having troubling completing a task the RESTful way. I have a "tasks" controller, and also a "complete_tasks" controller.
I have this in the complete_tasks_controller create action:
def create
@task = Task.find(params[:id])
@task.completed_at = Time.now
@task.save
end
I tried calling this:
<%=link_to "Complete task", new...
I've got a few small web projects where I'd like to get some user feedback however the services I've found are not cheap. To get to a useful level of features on UserVoice or Get Satisfaction I'd be needing to be on at least the $90/month plan on either service, multipled by a few sites is far more than I can justify spending for a few s...
I find myself doing the same things over and over again just to make one small modification to standard model output. I have a series of tables that I store information about products, etc. and all of which store prices. The prices are stored in US dollars but the output depends on the currency the user wants which is stored in a thei...
I want to be able to add a record which acts like a symlink. In other words I want to be able to store a record/object which will defer most attributes to another record/object.
The same as on a file system where a symlink points to another file (it own data), yet defers everything else to another file.
class Document < ActiveRecord::...
I'm having a problem with nested model forms that contain radio buttons, when I have multiple models all the radio buttons are treated as being in the same group.
My model contains a has_many relationship like this:
class Order < ActiveRecord::Base
has_many :order_items
accepts_nested_attributes_for :order_items
end
Class Orde...
Hi,
what do you prefer for testing JavaScript apps using Cucumber?
I never did it before - I only used Webrat for testing plain html.
I have tried Selenium, but it frustrated me and I didn't find any good documentation about Cucumber in combination with Selenium.
Best regards
...
In a Rails app I have Sales and Salespeople:
class Sale < ActiveRecord::Base
belongs_to :salesperson
end
class Salesperson < ActiveRecord::Base
has_many :sales
end
I have an ActiveScaffold for sales. I've switched on field searching and can successfully filter my sales by salesperson. However I only want to show a subset of salep...
I have two named scopes... both which work separately, but when combined do not work.
named_scope :total, :select => "COUNT(*) as days, AVG(price) as price, SUM(price) AS total", :group => :parent_id
named_scope :currency, lambda { |code| { :select => "*, price * #{(CurrencyRate.get_rate("USD", (code ||= "USD") ,1))} AS price" } }
...
I'm trying to setup Spree within my application (I'm open to using the Gem or running it in vendor mode).
I've reviewed the documentation and the wiki and I'm still a bit confused as to how it might work within my existing application. I have no problem using a separate database for Spree and customizing my application to pass data bet...
I am using Single Table Inheritance for managing different types of projects.
Models:
class Project < ActiveRecord::Base
end
class SiteDesign < Project
end
class TechDesign < Project
end
Edit action from projects_controller:
def edit
@project = Project.find(params[:id])
end
View edit.html.erb:
<% form_for(@project, :url => {...
I maintain legacy website running on Ruby on Rails and Goldberg CMS. Some things that are really trivial to do in Rails are difficult to implement in Goldberg. For instance: I want some content pages created by Goldberg CMS to use non-standard layout (currently, every Goldberg page uses default application.html.erb layout) - how can I do...
I'm coding a Rails project in a Windows environment and using Eclipse (with the Aptana plug-in) as my development environment.
I'm far enough along in my project now that I don't want to lose any of my work, and would like to start version controlling it.
What would you suggest I use? I've Googled and seen some responses for Git and T...
I'm trying to setup single table inheritance in my Rails app for a User model and its subclasses Member, Subscriber, and Staff.
I have a model file for each: user.rb, member.rb, etc
The user model is defined: class User < ActiveRecord::Base; end;
I subclassed the other models as such: class Member < User; end; and so on.
In my users t...
I've been using amcharts (a flash component) to produce charts from within my rails application.
I'm curious.. is there a GEM or plugin that allows me to include a charting component in my web app that lets users mix from any data sets they want, and produce basic charts on their own? It would take me ages to script such a tool...
Id...
I've created a simple Project model with four attributes:
Project name:string description:text complete:boolean user_id:integer
Then added some validation to the model:
class Project < ActiveRecord::Base
validates_presence_of :name, :description, :complete
end
Now, when I attempt to save a Project in irb, I am not allowed:
>> r ...
I'm using FasterCSV to import an uploaded file to a model, and it's working great for small files. However when I try to import a large dataset (21,000 lines) it takes ages and I get browser timeouts on the live server.
This is my current working code:
logcount=0
Attendee.transaction do
FCSV.new(file, :headers => true).each do ...
My basic use case is do some processing, set flash[:notice], and then redirect to a new page. From what I can tell, redirects reset the flash tag (please correct me if I'm wrong). Is there a way to gain persistence? Using sessions isn't an option, and I have hacked around the problem using cookies, but I think there's got to be a better ...
Hi. I'm using a paperclip plugin with an extension to write to the database. The default looks like: /screenshots/photos/24?style=thumb which gets caught already by the default routing in routes.rb.
I want to set it to :url =>':relative_root/:class/:attachment/:id/:style/:basename.:extension' (This produces URLs that I like on the pag...