I currently have the following link_to in my Rails application:
<%= link_to 'Remove this Person', @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
I would like to add the person's name in place of the "this person" for the link.
I don't appear to be able to do:
<%= lin...
If i have a loop such as
users.each do |u|
#some code
end
Where users is a hash of multiple users. What's the easiest conditional logic to see if you are on the last user in the users hash and only want to execute specific code for that last user so something like
users.each do |u|
#code for everyone
#conditional code for las...
I have a model, ContactEmail that has a date_sent attribute and an email_id, referencing another model Email.
I would like to create a bar graph which shows on the x-axis dates and on the y-axis the number of ContactEmails that were sent on a specific date.
I would like to also do the same, filtered for ContactEmails where email_id equ...
Hello,
I've created:
PhotoAlbum (id, name)
has_many: photos
Photo (id, name, photo_album_id)
belongs_to: photo_album
I want to allow a user to upload 1 or more photos. Per Upload whether it be 1 or more photos, they should automatically be added to a new album.
So the way i have it is, a user clicks upload photos:
They get the ...
Hello!
I have a very small question.
How can I convert these:
[172592596,93038592,154137572]
To look like these:
['172592596','93038592','154137572']
Thankful for all help!
...
I have a helper in my plugin test_plugin/lib/test_helper.rb:
module TestHelper
def test_render
render 'test_plugin/test_partial'
end
end
I have a partial test_plugin/app/views/test_plugin/_test_partial.html.erb:
<p>Hello World!</p>
In my application app/views/tests/index.html.erb when I do this:
<%= test_render %>
I get ...
Hi,
I would like to know if there is a way to add ruby code in a locale file. For example:
devise:
failure:
unconfirmed: 'You have to confirm your account before continuing. <%= link to "send confirmation instructions?", user_confirmation_path %>'
Thanks for your help!
...
I'm trying to modify the default behaviour of showing errors before the form to show them next to the fields instead.
I'm using this to achieve that:
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if instance.error_message.kind_of?(Array)
%(#{html_tag}<span class="validation-error">
...
I want to use a plugin to make most of my models inline editable, but I don't understand the following:
To use it, include
jquery.rest_in_place.js in your
template and execute the following in
your document’s onLoad handler:
jQuery(".rest_in_place").rest_in_place();
http://jan.varwig.org/projects/rest-in-place
Where do ...
I've been trying to setup a Single Table Inheritance model in Rails 3 in which the parent class also contains a has_many relationship. Unfortunately I can't get it to work. Here are three classes as an example:
class Article < ActiveRecord::Base
has_many :paragraphs, :dependent => :destroy, :autosave => true
end
class Paragraph <...
So in rails, if any of the input is not valid, the page returns back to the input page and red errors will show up next to that input_text or textarea.
For example,
<%
validates_presence_of :email
%>
It will say the error at the top, and the email input text turns into red.
However, when I separately made a valid checking statement...
I'm learning RSpec 2 with Rails 3. In order to set the contents of the tag in the layout for each page, I have a helper that can be used to set the title and then return it:
def page_title(subtitle=nil)
if @title.nil?
@title = ["Site Name"]
end
unless subtitle.nil?
@title << subtitle
end
@title.reverse.join " - "
en...
We already created a user model in the beggining of the project, but now (several migrations later) we would like to use the devise gem. Is it possible to add devise if the user model and table already exist? That is, is it possible to alter what is already done, or do we have to start all over again?
...
Hello, I have paper_clip installed on my Rails 3 app, and can upload a file - wow that was fun and easy!
Challenge now is, allowing a user to upload multiple objects.
Whether it be clicking select fileS and being able to select more than one. Or clicking a more button and getting another file upload button.
I can't find any tutorials ...
In Rails 3 I'm trying to call alias_method from my before_filter but I'm getting this error: NoMethodError in MyController#index
class ApplicationController < ActionController::Base
before_filter :my_test
protect_from_forgery
helper :all
def my_test
debugger
alias_method :new_method_name, :old_method_name
end
en...
Hello,
Has anyone been able to get the jquery-html5-upload plugin to work with Rails 3 + PaperClip + S3? Know of any tutorials?
http://code.google.com/p/jquery-html5-upload/
Thanks
...
I'm a Rails newbie, and I was initially using NetBeans + JRuby to make Rails apps (was using JRuby because it was a quick start - I don't need to interface with any Java libs).
Then because of (a) many gems are not available for JRuby, and (b) most of the Rails webshosts don't support JRuby, I decided to use Ruby MRI.
So I got everythi...
There is code to use Facebooker gem (which uses the old Facebook REST API). Does someone have experience how to convert those code to
using Facebooker2, which uses the new Facebook Graph API?
For example, Facebooker has Facebooker::Session and Facebooker::User and they are both gone in Facebooker2.
I can't find too much docs on the tw...
I'm watching a Ryan Bates screencast on polymorphic relationships, and he uses this private method for finding all comments related to a nested model.
So I could find all the comments of a given Post with this :
def find_commentable
params.each do |name, value|
if name =~ /(.+)_id$/
return $1.classify.constantize.find(value...
I'm upgrading my Rails app to work with Ruby 1.9 and I keep encountering errors like this:
Anonymous modules have no name to be referenced by
/home/foo/.gem/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:585:in `to_constant_name'
/home/foo/.gem/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.r...