I'm using the Polymorphic fork of Paperclip in Rails, but have been having some massive problems with regards to the overwriting of unique filenames. No matter whether I put a time-stamp (more on that in a second) or the id of the asset in the URL, if a file with the same name is uploaded subsequently, then the previous one is overwritte...
I am having some issues with paperclip, on my new page, I have a paperclip file that relates to aonther model. If I don't upload the keynote at the time of creating I can't go back and edit it on the edit page, I'm pretty sure its something todo with the fact that its related to another model.
Here is my form partial
<% form_for([@proj...
My example form
<% form_for @ad do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :ad_type_id %><br />
<%= f.collection_select(:ad_type_id, AdType.all, :id, :name) %>
</p>
<p>
<% @ad.ad_properties.each do |property| %>
<%= property.name %>:
<% f.fields_for :ad_values do |value_field| %>
<%= value...
Hey guys ive got the following Model for Accounts
require 'net/http'
require 'uri'
require 'date'
class Account < ActiveRecord::Base
validates_presence_of :username, :password, :on => :update
validate :valid_expiry_date, :on => :update
def valid_expiry_date
reply = Net::HTTP.get URI.parse("http://api.rapidshare.com/cgi-bin/rsapi....
Hi,
I would like to know if it is possible in rails to run some test cases through my application. I mean, i want show the test results to users. So i was thinking to be able to call my tests through a controller and put the tests output in a dialog. Imagine that i'm doing an application where before to apply a rule, i want to run some ...
I've an application integrated with Facebook Connect. My application is deployed on different environments (production, staging, development) with different domains.
Is there a way to set up Facebook app, so that it work with all my environments? Or should I create separate facebook apps for each env?
...
I have a ul filled with links in my layout/application.html.erb and want the current location link be marked with class="active".
Now I'm using:
<%= link_to 'About Us', { :controller => 'aboutus' }, :class => "menu#{' active' if params[:controller] == 'aboutus'}" %>
But it looks pretty nasty to me.
Anyone has a better idea?
...
I'm trying to format a date in Rails 3 using the new syntax as described in the code:
http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/date/conversions.rb
by using the following syntax in an initialiser:
Date::DATE_FORMATS[:my_format] = '%m %d %Y'
I am then referencing dates in my view like so:
co...
I'd like to build a webapp in Rails in which I'd like to determine every pixel's color of a given image (JPEG). Is there any possibility to do that with Rails or JavaScript? The goal is to write an algorithm which determines the "middle color" of the image and uses it for background color of the site.
Any suggestion would be appreciated...
Hello,
I'm trying to prevent a record that has a relationship to another record from being deleted. I can stop the deletion but not send a flash message as I had hoped!
class Purchaseitem < ActiveRecord::Base
before_destroy :check_if_ingredient
...
def check_if_ingredient
i = Ingredient.find(:all, :conditions => "purchaseite...
If it doesn't, what's the half-life of it?
It it does, where can find that information?
On my server I found a few logs for each of my releases. But they only date back a few days.
Specifically, I am looking for emails that were sent while my mail server was down two weeks ago.
...
I for the life of me can't figure out the correct syntax to show the count of events before and after today.
Here's my awful and disgusting attempt:
Events.find(:all).select {|e| e.date > Time.now}.size
The trouble is the > or < operators don't work with Time.. :D
...
I have installed both shoulda and factory_girl, I can run shoulda just fine, but when I add this:
require 'factory_girl'
Factory.define :user do |u|
u.mail '[email protected]'
u.pass 'secret'
end
to my test/test_helper.rb I'm getting this error:
/test/test_helper.rb:1:in `require': no such file to load -- factory_girl (LoadError)...
Alright, I know my title is a little obscure but it best describes the problem I am having.
Essentially, I have a list of users, and want to be able to edit their information in-line using AJAX.
Since the users are showing up in rows, I am using a partial to render the data and the forms (which will be hidden initially by the ajax), ho...
I've got a CopiesHelper module with a method cc.
In my ApplicationController, I have
helper :all
helper_method :cc #just tried putting this in recently
If in another one of my Controllers, I try using the cc method, I get
undefined method 'cc' for #<OtherController:0xblublublublub>
Am I missing a step here?
...
In my Rails app, I loop through an array to create a list of conditions that must be joined by OR. Below is the basic flow of how I currently do so.
conditions = nil
set.each do |value|
condition = value.to_condition
conditions = conditions ? conditions.or(condition) : condition
end
Obviously, it's not beautiful, but I still don't...
I have a model called photo with this:
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 10.megabytes,
:resize_to => '800x600>',
:thumbnails => {
:thumb => '100x100>',
:large => '450x600>',
:medium => '64x64'...
Hi Guys,
I have a group of assets, let's call them "practitioners".
I'm displaying these practitioners in the header of a calendar interface.
There are 7 columns to the calendar. 7 columns = 7 practitioners per view/page.
Right now:
if the first page shows you practitioners 1-7, when you go the next page you will see practitioners 8-1...
I need to prevent access to public directory with .htaccess kind of mechanism. It means that hitting http://localhost:3000 should ask for credentials before it shows anything else. Is it possible?
...
When ever I run make I get this 'uninitialized constant RDoc::RDoc' error
rake -T
(in Main)
rake aborted!
uninitialized constant RDoc::RDoc
C:/Ruby186/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
(See full trace by running task with --trace)
--edit
Running --trace it ...