I've got a rails model using Paperclip that looks like this:
has_attached_file :image, :styles => { :normal => ['857x392#', :png] },
:url => '/assets/pages/:id/:basename.:extension',
:path => ':rails_root/public/assets/pages/:id/:basename.:extension'
validates_attachment_size :image, :less_th...
I have a setting in environment/production.rb of HEROKU = true
This should change my has_attachment has to use s3 instead of the file system, but it doesn't. What's wrong with my logic?
has_attachment :content_type => :image,
:storage => ($HEROKU ? :s3 : :file_system),
...
Thanks!
...
I would like to let my users create Ruby scripts that do computation on some data residing on the web server and then outputs results. The scripts are executed on the server. Is there any way to do this securely?
More specifically, I would like to:
restrict the resources the script can use (memory and cpu), and limit its running time
...
My goal is to print a json document with the structure described in the chosen answer on this thread. I only have one level of sub categories (2 total, including root) so it should be a little bit easier than the problem there. The problem I'm having is with efficiency. With only ~20 root categories the recursion is causing my script to ...
Building an app using a calendar on a Google Apps domain that has SSL enforced domain-wide. I initially found the problem when building a Rails app using the GCal4Ruby library, which used the allcalendars feed URL with a non-SSL protocol (GCal4Ruby debug output snippet [sic]):
…
url = http://www.google.com/calendar/feeds/default/allcale...
I want to use page_cache with will_paginate.
There are good information on this page below.
http://railsenvy.com/2007/2/28/rails-caching-tutorial#pagination
http://railslab.newrelic.com/2009/02/05/episode-5-advanced-page-caching
I wrote routes.rb looks like:
map.connect '/products/page/:page', :controller => 'products', :action => 'i...
I have an ecommerce store that I am building. I am using Rails/ActiveRecord, but that really isn't necessary to answer this question (however, if you are familiar with those things, please feel free to answer in terms of Rails/AR).
One of the store's requirements is that it needs to represent two types of products:
Simple products - t...
Hello there
Is there a way to set session cookie work for all subdomains (e.g. *.domain.com) from Merb configuration file (config/init.rb)
Looking for something like
Merb::Config.use do |c|
c[:session_cookie_domain] = '.domain.com'
end
...
We’ll be releasing shortly a companion Rails application to our existing Rails app. We will be running the companion app alongside our existing app on the same servers.
My question concerns the databases. My hosting provider generally would configure a 2nd distinct database for the new application - secondappname_production. However,...
I have the following array:
[["2010-01-10", 2], ["2010-01-09", 5], ["2009-12-11", 3], ["2009-12-12", 12], ["2009-12-13", 0]]
I just want to sort it by the second value in each group and return the highest one, like i want to the output to be 12 with the given input above.
update
I might add that I made this into an array using to_a, ...
I am attempting to add in a form field that should allow me to add a record into a join table. The table name contains the ids of the following:
log_id
node_id
So naturally, my models is setup as follows:
class Log
has_and_belongs_to_many :nodes
end
class Node
has_and_belongs_to_many :nodes
end
The objective is that when I crea...
I have a program written in Ruby and C. The C portion is a shared library, which is an extension for the Ruby program. I want to profile the C shared library I wrote, using gprof. I compile the shared library like this:
gcc -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-al...
define_mehtod could be used to define methods:
define_method(:m) do |a|
end
which is equivalent to the following:
def m(a)
end
However, what is the equivalent form of the following using define_method:
def m(a=false)
end
Note that I'd need to be able to call m() without giving any argument.
...
How do I extend the range of the date_select in Ruby?
It only goes as far as 2005 and I'd like to use it for the date of birth.
...
Hi,
I have 2 questions about authlogic:
1 - how to get cause of unsuccessful session creation (for example - not confirmed, blocked, wrong pass etc) to use it in app logic (route to another page for confimation, or re-enter pass etc)?
2 - question about integration formtastic and authlogic. How to show error messages on session creatio...
If I have two objects, one being referenced in another. Then in the first object can I write a method which will give me which other objects it is being referenced in?
...
As I've been writing test suites for a Rails app, I've noticed that there are two different ways to create tests, a test block and a regular method:
test "the truth" do
assert true
end
vs.
def test_for_something_else
assert true
end
Is there any difference between the two testing structures? When should I use one over the othe...
I always run autospec to run features and RSpec at the same time, but running all the features is often time-consuming on my local computer. I would run every feature before committing code.
I would like to pass the argument in autospec command. autospec doesn't obviously doesn't accept the arguments directly. Here's the output of autos...
I've found the method set_log in the documentation, I just can't figure out the syntax to call it. Here's what I tried:
require 'ruby-aws'
Amazon::Util::Logging.set_log('my.log')
NoMethodError: undefined method `set_log' for Amazon::Util::Logging:Module
...
I modify my RoR application to calling a create.js.rjs after created an item. I want to reload a specify div in my page after I create an item, how can I do that?
When my div have a ruby object like this:
<div id="categoryList">
<% @categories.each do |category| %>
<%= content_tag(:dt, category.name, :class => "menu-table")%><%...