The app can have the following URLs:
/projects/
/projects/3
/projects/3/photos
/projects/3/photos/312
I'd like to know how in Rails 3 I can look at the current URL and know which of the lines above is currently active, so I can add a class="selected"
Additional exmaple..
If the user's browser is on: /projects
And the Nav loo...
hi
i have an element in a array such that,
[#<Name id: 23, first_name: "anderson", last_name: "gorge">]
how can i remove the array block, so that i want it as
#<Name id: 23, first_name: "anderson", last_name: "gorge">
without array block
...
I am using the following:
send("#{done_event.class.name.tableize}_path", done_event.id)
An example is done_event is a specific instance of ContactEmail.
I would like this to represent the path contact_email_path(done_event.id) which would translate to something like contact_emails/1
However, the result I get is contact_emails.1
Not...
Hi all,
new to rails and trying to get youtube-g to work... I am having a difficult time passing a users search from the form_tag to the controller.. for example:
user lands on page, enters - tiger videos - in text_field_tag
controller takes - tiger videos - and searches
user lands on another page displaying the results...
user lands ...
Hello,
I have the following helper in my application_helper.rb file:
def topmenu
pages = {
"projects" => projects_path,
"photos" => photos_path
}
pages.map do |key, value|
classnames = %( class="current") if controller.controller_name == key
"<li#{classnames}>#{link_to(key, value)}</li>"
end
...
Hi,
I just succeed to set in place my rails server. But when I'm trying to add a new "machine" I have an error. I can see this in logs
ActionView::TemplateError (undefined method `owner_id' for #<Machine:0x7f85a0d279e0>) on line #49 of app/views/machines/_form.html.erb:
46: </div>
47: <p>
48: <%= f_machine.label :owner %><br />
49:...
I am working on a Rails 3 project where there is place for date input within a form. The text field with the date uses a date picker so there is no concern about the date being entered in a wrong format, however the date is being displayed in the :db format (e.g. 2010-01-21).
(Note: this is specifically in form fields - e.g. <%= f.text_...
Hello,
I have installed multiple state_machine gems to my app to use them for a notification system but every time I run into an ActiveSupport issue. It usually looks something almost identical to this:
>> m = Message.new
TypeError: wrong argument type nil (expected Module)
from /home/Ryan/appname/app/models/message.rb:2:in `i...
We're migrating a site from a proprietary framework to Ruby on Rails (v2.3). The current framework sometimes puts /base/ at the start of the URL for no discernible reason, and I'd like the existing URL to work, even though we won't give it out any more.
My current solution, which I don't like, is to define the routes once on the main m...
Hi,
I have this simple has_and_belongs_to_many association between users, which works perfectly.
However, I would like to add a friendship relation between all new users created and the first user (yup, just like MySpace's Tom), directly in the Create method:
def create
@user = User.new(params[:user])
if @user.save
@user.frie...
I have an integer output from a private controller action that I would like to store 'encrypted' in my database. What methods would you use to codify this integer such that I can retrieve up to ~200 of these numbers easily and quickly to be served in a view to the right user?
...
Hi all. I'm trying to build a mysql view and am struggling a little. The relationships/tables involved are:
Question
#fields - subject_id, privacy, keywords
has_many :taggings
has_many :tags, :through => :taggings
has_many :gradings
Tagging (polymorphic join table)
#fields - taggable_type, taggable_id, tag_id
Tag
#fields...
Hi there,
We got a Rails 3 Server based on Ruby 1.9.2 running on a MYSQL DB and Problems with the time.now and time.zone.now setting.
For better explaination we assuse its 13:00 UTC right now.
Ubuntu Systemtime is set to 15:00 UTC +02:00 (Thats CEST (Central European Summertime) and is correct for our Timezone).
The Rails time (time....
Hi,
I have a rails server that has a page with canvas tag containing some images and user interface. Some objects inside the canvas have on mouse click events assigned. I wonder if it's possible to execute ajax calls on clicking the item then processing some data inside the ruby on the rails server and comeback to canvas changing some o...
Hi,
I'd like to give a link to the contact us page on failure of a validation. I've tried this to no avail:
validates_acceptance_of :not_an_agency, :on => :create,
:message => "must be confirmed. If you are an agency please #{link_to "Contact Us, contact_path}"
Anyone know how to get past this one?
Jack
...
We're transitioning from 'frozen' rails gems to using bundler and would like to maintain the rails gems with patches, merges etc. say from an external git source. What's the easiest way to set this up, adding gemspecs to the patch branches etc.?
...
Basically what I want to do is to log an action on MyModel in the table of MyModelLog. Here's some pseudo code:
class MyModel < ActiveRecord::Base
validate :something
def something
# test
errors.add(:data, "bug!!")
end
end
I also have a model looking like this:
class MyModelLog < ActiveRecord::Base
def self.log_so...
How to redirect to a specific page on successful sign up using rails devise gem?
...
Hi,
I'm using accepts_nested_attributes_for with the following models:
User model:
class User < ActiveRecord::Base
has_many :competences
has_many :skills, :through => :competences, :foreign_key => :skill_id
accepts_nested_attributes_for :skills
end
Skill model:
class Skill < ActiveRecord::Base
has_many :competences
has_m...
Is it possible to use require in a module program?
...