I find it odd that rails doesn't have a standard way of clearing out old sessions (file, ActiveRecord, or otherwise). There's a rake task that deletes all of them, which is not what I need (need to only delete sessions older than X weeks).
I can write a 3-line script and run it periodically easily enough, but wanted to first check if th...
This question relates to cleaning up the view and giving the controller more of the work.
I have many cases in my project where I have nested variables being displayed in my view. For example:
# controller
@customers = Customer.find_all_by_active(true)
render :layout => 'forms'
# view
<% @customers.each do |c| %>
<%= c.name %>
<% ...
Hi,
I need a way of implementing a calendar for a webpage to show events this month for a local society i am a member of. I am looking at doing this project in RoR. But have no experience of calendars in RoR can any one recommend any good plugins for RoR for me to play with?
Thanks in Advance
Dean
...
hi,
I tried deploy ror app using capistrano. when i ran the command 'cap deploy:migrations", i got the following errors:
Missing these requried gems:
rake aborted!
Unknown database 'hylog_production'
do i have to resetup the databases manually on production server?
...
HAML:
= link_to 'redeem', redeem_admin_organization_path(organization), :class => 'button_short live redeem'
Controller:
def redeem
@organization = Organization.find(params[:id])
@organization.update_attribute('accumulated_credits', '0')
end
redeem.js.haml:
== $("#organization_#{@organization.id} .redeem").html("#{escape_javas...
How do you guys debug your Rails apps? I have seen a link to datanoise.com that is supposed to show how to use ruby-debug with Textmate using a bundle.. but it looks like the page is down. Does anyone know how to set this up? Thanks!
...
Hi,
I keep getting this error
compile error
/Users/dean/src/carolian/app/views/layouts/events.html.erb:10: syntax error, unexpected ',', expecting ')'
/Users/dean/src/carolian/app/views/layouts/events.html.erb:11: syntax error, unexpected ',', expecting ')'
"jquery-ui-1.8.2.min", "application").to_s); @output...
I have followed this rail...
I am working through a tutorial with the following code:
<h3>New Comment</h3>
<%= render :partial => @comment = Comment.new,
:locals => { :button_name => "Create" } %>
I believe that 'render :partial => @comment' works like 'render :partial => "comment", :object => @comment'
Where does ' = Comment.new' fit in?
Is it shorthand f...
To generate <span> or inline elements using a loop, so that the result has no white space between them:
%div
- 5.times do
%span> hello
the above will create
<div><span>hello</span><span>hello</span><span>hello</span><span>hello</span><span>hello</span></div>
(practically, it is no use to stick "hello" together, but say, if we...
Hi,
I am using jquery ui in a rails application. I want to load content of the tab via ajax when the tab is clicked. I have evverything set up correctly, i.e. my controller responds to a xhr request and it simply replaces the content of a certain div (inside the tab content). This all seems to work fine with prototype, however, If I try...
Does anyone know how I can load a Ruby on Rails partial into a jquery dialog? I want to do something like this
$('#advancedExerciseSearchLink').click(function() {
$('#advancedSearch').load('/path/to/advancedsearchform_partial').dialog('show');
}
I could pre-load the partial on the parent page and just show it when the advanced sear...
When adding a key to an existing model (with existing data) via MongoMapper, I can create new documents with the new key but when trying to access existing documents using that same key it fails stating that it's an "undefined method."
I was wondering if anyone had any insight.
Thanks in advance!
(Yes, these examples are truncated.)
...
I am using Heroku for my production environment so I need to load the paperclip files into different directories.
For development I want it to continue in the current /system default, and in production I want to pass the :path variable to a /tmp directory per Heroku.
How do I do this? Am guessing maybe set something in the environment...
Hello,
My objective is to convert form input, like "100 megabytes" or "1 gigabyte", and converts it to a filesize in kilobytes I can store in the database. Currently, I have this:
def quota_convert
@regex = /([0-9]+) (.*)s/
@sizes = %w{kilobyte megabyte gigabyte}
m = self.quota.match(@regex)
if @sizes.include? m[2]
eval("se...
I have done the front-end of my design, but I have no experience in web programming. Would like to pick up a language asap so that I can deploy the product. Which is faster to pick up between the two? I know there is always debate in which is better. I think either one serves well for me, but I want to know which one is easier to learn, ...
I need to retrieve all rows from a table where the created_at timestamp is during a certain hour ... say 04:00 and 05:00. Anyone know how to do this?
...
I have a polymorphic association that looks like this:
class Line < ActiveRecord::Base
belongs_to :item, :polymorphic => true
end
class Education < ActiveRecord::base
has_many :lines, :as => :item
end
class Work < ActiveRecord::base
has_mayn :lines, :as => :item
end
I'd like a simple way to create a new Line from the parent...
I get back the responseXml as a javascript object XMLdocument. How do
i parse it to just return the body?
here is my code snippet:
goog.net.XhrIo.send("/blogs/create?authenticity_token="+
goog.string.urlEncode(authtoken), function(e) {
var xhr = /** @type {goog.net.XhrIo} */ (e.target);
var responseXml = xhr...
I want to get the number of bytes occupied by a variable or type in Ruby. Is there an equivalent SizeOf() function in Ruby on Rails?
...
I have a User model that has_many :posts. If I wanted to make a named_scope for finding users with at least one post would this be correct?
named_scope :at_least_one_post, :joins => :posts, :group => "users.id"
or should I take it a step further and do
named_scope :at_least_one_post, :joins => :posts, :group => "users.id", :hav...