Hi - I'm trying to capture the value that's throwing a uniqueness error (or for that matter, any other type of built-in validation) to display it in the :message option. Here's what I tried (didn't work)
# inside the model
validate_uniqueness_of :name, :message => "#{name} has already been taken" # also tried using #{:name}
I could us...
how do i add styles to actionviews helper tags. like the following
<%= link_to "Home", :controller=> "home", :action=> "index", :style=>{:position=>"absolute", :top=>"0px"} %>
is something like the above achievable. I dont want to add css classes.
Thanks.
Update-- sorry Salil. it doesn't work for link_to_remote. I need a solution th...
I know there are tons of questions about paperclip, but I failed to find the answer to my problem.
I know its prob just something simple, but I I'm running out of hair to pull out.
I have paperclip working on other parts of my project, they work with no problem, however, a certain scaffold fails to upload, all the attributes to the upl...
In my model example Game, has a status column. But I usually set status by using symbols. Example self.status = :active
MATCH_STATUS = {
:betting_on => "Betting is on",
:home_team_won => "Home team has won",
:visiting_team_won => "Visiting team has one",
:game_tie => "Game is tied"
}.freeze
def viewable...
I have a Lexicon model, and I want user to be able to create dynamic feature to every lexicon.
And I have a complicate search interface that let user search on every single feature (including the dynamic ones) belonged to Lexicon model.
I could have used a serialized text field to save all the dynamic information if they are not for se...
Hi,
I am creating a small rails app for personal use and would like to be able to upload excel files to later be validated and added to the database. I had this working previously with csv files, but this has since become impractical.
Does anyone know of a tutorial for using the roo or spreadsheet gem to upload the file, display the c...
I'm creating a simple site with a gallery. I have a photos model which has a page for each photo with its info and an image.
I'm unsure how to create a gallery from the photos.
The gallery model has_many photos, the photos model has_and_belongs_to_many galleries.
I thought of adding a gallery.title field on each photo page so I'd have ...
I have a page that's taking ages to render out. Half of the time (3 seconds) is spent on a .find call which has a bunch of eager-loaded associations. All i actually need is the number of associated records in each case, to display in a table: i don't need the actual records themselves. Is there a way to just eager load the count? Her...
i am facing a precarious condition here. I need to partially render a page that does not have a leading underscore.
<%= render(:partial => "contact" ,:controller=>"home") %>
this will look for
app/views/home/_contact.html.erb
but i want it to look for
app/views/home/contact.html.erb
is there a way of doing this.?
Thanks
...
Hi,
I am using the code from this tutorial to parse a CSV file and add the contents to a database table. How would I ignore the first line of the CSV file? The controller code is below:
def csv_import
@parsed_file=CSV::Reader.parse(params[:dump][:file])
n = 0
@parsed_file.each do |row|
s = Student.new
s.name = row[0]
...
I wand to change the regular expression in my application.js file from within a rails controller.
Is that possible?
...
Hi there,
I'm trying to request data from another Rails app, but I keep getting a "URL not found" error.
Is it possible to use the debugger to figure out the intended URL and parameters for an intended ActiveResource call?
For example, I'd like to make a GET request with the following parameters:
https://some_server.com/employees/searc...
Hi, I'm using the will paginate gem from http://github.com/mislav/will_paginate
Routes:
map.resources :post do |post|
post.resources :comments
end
Post Controller:
@post = Post.first
@comments = @post.comments.paginate :page => params[:page], :per_page => 10
My problem lies in the view:
<%= will_paginate @comments %>
This gen...
This is deals_controller.rb. And it works like this, except two things.
Not sure how to call Deal.count to add in my flash[:notice] . I get the hunch that its not calling something global.
I need that contional statement back, as I'm pretty sure its responsible for actually adding the new @deal . So I assume my syntax is off. Do note, ...
I have the following code in /config/initializers/chargify.rb
Chargify.configure do |c|
c.subdomain = 'example'
c.api_key = '123xyz'
end
But I have different settings for development and production.
So, how would I have a different set of variables values based on environment?
...
HI,
My client want to implement directions on google map (googletransitdata) with rails application. i have not how to do that. i didn't work with Google API's so far. i don't know how to proceed ... can any one help me regarding this. thanks in advance..
...
Is there any way (middleware, etc) to tell the rails router that any route beginning with /photos should be considered as static data and should only be served from the /public/photos folder?
What i mean is that if the resource is not found, a 404 should be returned directly, without loading all rails stack.
This is for my dev env (si...
Hello world!
We have a form to submit ratings for a certain restaurant in a in our views/restaurants/show.html.erb. If there is a validation error we get redirected back to views/restaurants/show.html.erb but the validation messages do not appear. We figured out that this happens because we lose the messages using redirect_to(@restauran...
I'm trying to install a software called Teambox in my Dreamhost shared account, following these instructions.
I have no experience with Rails. I just want to install the software in the shared hosting.
In this shared hosting, all dependencies are ok, but I have to create the dabatase from their panel. I can't create in command line (ss...
I am having problems with conflicting versions of Ruby that I have installed. I had 1.8.6 and then installed 1.8.7 and it has caused problems. I get the following error when trying to run my ruby on rails app:
/usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version (1.8.6) doesn't match executable version (1.8.7) (RuntimeErro...