I don't understand why one method would work and the other would throw a NoMethodError if they come from the same lib file.
# app/views/bunnies/show.html.erb
<% if logged_in? %>
<%= current_user.login %> |
<%= link_to 'Logout', logout_path %> |
<% if authorized? %>
<%= link_to 'Edit Details', edit_bunny_path(@broker) %> |
<%...
Here's the code:
render :file => @somedir + "/blah.xml"
...but the resulting MIME type is text/html when I check in FireBug. How do I specify a MIME type in this case?
...
Anyone know how to take the awesome method mentioned in this tutorial and have the stylesheet tags generate with absolute URLs?
...
<%= link_to 'Show', buddy, :only_path => false %>
Doesn't seem to work. I need the full path: http://www.my-server.com/buddy
How do I do this?
...
I have a FooController that responds to HTML and JS (AJAX) queries:
# app/controllers/foo_controller.rb:
class FooController < ApplicationController
layout 'foo'
def bar
respond_to do |format|
format.html # foo/bar.html.erb
format.js # foo/bar.js.erb
end
end
end
The templates to support it:
# app/views/lay...
I have the following code:
for attribute in site.device_attributes
device.attribute
end
where I would like the code to substitute the value of "attribute" for the method name.
I have tried device."#{attribute}" and various permutations.
Is this completely impossible? Am I missing something?
I have considered overriding method_mis...
I am having issues using the :collection command for a partial within a form I am creating in rails. I would ideally like to use the :collection command, so I can easily manipulate this section in my .rjs templates (the form will submit and reload the form when the check box is changed, it's a to-do list).
This code works:
<% for...
In my Ruby on Rails app, I have a User table and a Foo table. I also have a User_Foo table that stores the cross reference data.
I have everything wired up for my views to work as I want, however, now I need to make sure that the same Foo doesn't get assigned to my User more than once.
What's the best way to do this?
I assumed that I ...
I am working with Rails fixtures for testing my rails application. It is all good except one of my database columns is supposed to hold YAML content. But, I am sure how to put the YAML markup I want to load into my database inside the YAML file. Here is an example:
mvnforum:
name: mvnforum
abstraction_type: SVN
url: src: ...
I have a form I am submitting via AJAX (using prototype and the built-in rails 'form_remote_tag' helper).
What I would like is to update one div (a status area) if there are form validation errors but a different div (the div where the form lives) if the submit goes through sucessfully.
My code looks something like this:
<div id="recip...
My doubt is the following:
I will start to developing a Rails application that will accesss a lot of RSS feeds or crawl sites for data (most news). It will be something like Google News but with a different approach, so I'll store a lot of news (or news summaries), classify them in different categories and use ranking and recommending t...
I'm having a weird problem, where tagging works fine on my development machine, but when I deploy to the production server, I get this error in the log:
ActionView::TemplateError (undefined method `tags' for #<Person:0x98bb9d4>) on line...
There is an entry in the production.log file that states that has_many_polymorphs is loaded, so ...
How can I accomplish this?
<% for agent in @broker.agents %>
...
<% if agent.cell %><span class="cell-number">Cell: <%= agent.cell %></span><% end %>
...
<% end %>
I want to test to see if the agent has a cell number, and if so, display what's inside the conditional. What I have currently doesn't seem to work; it just displays ...
My rails model has code that is attempting to define_method(method_name) inside the model.
I keep getting:
NoMethodError: undefined method `define_method'
What am I doing wrong? Am I doing this in the wrong place. I need this method attached to this model. Where else can I define this method?
EDIT:
For those asking to see the code:
...
Do the major web application frameworks (Rails, Django, etc) have libraries that provide functionality for signing in, signing up, creating usernames, changing passwords, and managing lost passwords?
It seems to me that this is common functionality that should be supported by some standard library, but I haven't seen anything in my sear...
How do you access a MySQL relation using RoR?
...
I am developing some school grading software and decided to use Github to host the project. After building some code on my Ubuntu box I pushed it to Github and then cloned it down to my MacBook Pro. After editing the code on the MBP I pushed it back to Github. The next morning I tried to update my repo on the Ubuntu box with a git pull ...
I have a polymorphic association in a Ruby on Rails model. In the migration, I have:
create_table "offer_defs" do |t|
t.integer "product_def_id"
t.string "product_def_type"
...
end
I would like to add an index for this association. I am hesitating between the following options:
add_index :offer_defs, [:product_def_id, :produ...
The rails books and web pages I've been following have all stuck to very simple projects for the sake of providing complete examples. I'm moving away from the small project app and into a realm of non-browser clients and need to decide where to put code that is shared by all involved parties.
The non-browser client is a script that run...
Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father_id and mother_id (2 parents). Below is basically what I want to do, but obviously I can't repeat the :children in a has_many (the first gets overwritten).
class Person < ActiveRecord::Base
belongs_to :fath...