Is it possible to enforce a 'content type' validation in paperclip without enforcing a 'presence' validation (i.e. allow blanks)? I currently have:
class Person < ActiveRecord::Base
has_attached_file :picture
validates_attachment_content_type :picture, :content_type => ['image/jpeg', 'image/jpg', 'image/png']
end
However, this fai...
I have a rails app that I host for multiple users as useraccount.mysite.com. I want to have the option to allow my users to have their own url (useraccount.com) but still host the app using my shared server. So they should be able to access useraccount.mysite.com or useraccount.com and it should return the same stuff. If they goto use...
Artists have many Events. Events have many Artists. The join between these two models is called Performances.
I'm trying to associate Artists with Events on the Event add/edit page. I would like to be able to add an Artist only if it doesn't exist, and create the join (performance) regardless. An Artist should be associated with an Even...
I'm working on a website where the frontend is powered by AJAX, interacting with the server in the ordinary RESTful manner and receiving responses as JSON.
It's simple enough to manage POST, DELETE, and PUT requests, since these won't differ at all from a traditional approach. The challenge comes in GETting content. Sometimes, the clien...
Hey,
I'm very new to rails and have been trying to experiment with using Mongodb on a web app.
I have been following this railscast tutorial here word for word and have been running into issues with it not connecting to my local Mongodb.
I'm sure Mongodb is up and running since mongod shows up in my activity monitor and going to
ht...
I have a custom Java Tree class (from stanford parser,) that I am able to work with in JRuby on Rails.
What I am trying to figure out how to do is to output this tree class to XML through rails
The tree class describes a word tree derived from a parsed sentence. Each tree may have multiple child trees depending on the structure
Here i...
I currently authenticate that users can edit their own content only by:
@posts = current_user.posts.find(params[:id])
Is there an easier way to do this across all controllers?
I have a before_filter that requires a user must be logged in, but it doesn't check who the individual user is.
I'm wondering if there is a more elegant solut...
I have Ruby on Rails app using DataMapper, the database is SQLite, the app is hosted on Heroku. I would like to load the DataBase with data from a spreadsheet, however, I don't know the most efficient way...please help!
As an example, let say I have a User model with fields:
Name
Age
Birthday
Hometown
...
Hi Folks,
I'm trying to run Rails 3 beta 4 & Ruby 1.9.2rc on Ubuntu 10.04. It worked initially, but after doing my first bundle install/package, I now get the following errors in all rails projects. Even a basic 'rails new testproject' followed by a rake brings up the error messages.
In short, I'm stumped. Any help regarding what could...
I have a form on my site that lets users direct a message at other users, but I want to ensure that they can't direct a message at themselves.
The class has attributes :username and :target_user, and I just want to set a validation that checks to make sure that these attributes can't have the same value, before anything gets saved.
I f...
Hi folks,
I've spent a fair bit of time with PHP & Python frameworks and recently thought I'd branch out to rails. The framework itself I like, but I seem to spend at least half my development time navigating through odd bugs and/or version incompatibilities between rails/ruby/rake/gems.
I'm happy to battle through it all if it gets le...
I noticed that a rails plug-in I am using has had several fixes made to it, and im a little worried about all the other rails apps i have written.
Ideally I would like to have a script that can compare the checked out version of the plug-in against the repo version. Does anyone know if rails stores this info anywhere or if there is a p...
I have found a lot of information about adding form helper methods (see one of my other questions) but I cant find anything about adding helper methods as if they where defined in application_helper.rb
Ive tried basically copying application_helper.rb from a rails app into the gem but that didn't work.
Ive also tried:
class ActionVie...
G'day all.
In a Rails app I have 2 models: users and spots, with a habtm relationship and join table. In the spot/show action I can create a form to ask the current user if they have visited this current spot (checkbox) and click save to create a record in the join table.
This works well (so I know my models and relationships are all g...
$param=k.chomp.split("\t")
how to find the lenght of $param thats is having class array.
actully when i m writing
puts $param.class
i got the o/p like Array.
now how to find the length of this array plzz help me
i tried with $param.length but its not working
...
I'm using Rails to generate a PDF with the executable wkhtmltopdf and then using send_data to send the result back to the user as a PDF file.
view = ActionView::Base.new(ActionController::Base.view_paths, {})
html = "<h1>A heading</h1>"
pdfdata = `echo '#{html}' | #{RAILS_ROOT}/lib/pdf/wkhtmltopdf-i386 - -`
send_data pdfdata, :file...
Hi,
lets say i have the following resource
map.namespace :admin do |a|
a.resources :users
end
to access the users index action I would have to type
/admin/users
How can I translate this route to different languages?
map.namespace :admin do |a|
a.resources :users, :as => ipsum
end
would result in
/admin/ipsum
How can i c...
Hi guys,
I'm trying to do a validates_format_of on the latlng object that is passed back from Google Maps API. I've got the map set up perfectly so that when I click on a point in the map it fills in a text-field with the latlng (which looks like this: 46.320615137905904, 9.400520324707031). I'm storing this value as a string in the db ...
It seems http://api.rubyonrails.org/ is not for rails 3. Where can I get the api doc of rails 3?
...
Hello,
I'm using will_paginate in my rails application, it's working fine but I would like to use ul li list for my webdesigner layout. Actually with my code, it's only rendering
my view :
<div class="pagination">
<ul><li><%= will_paginate @organizations %></li></ul>
</div>
My source code:
<ul><li><div class="pagination">
<span...