I'm trying to learn ruby on rails. I've been going through a tutorial, but I've gotten stuck.
It has me using start_form_tag and end_form_tag around an input form. However, when I access the page, I get undefined method 'start_form_tag' for #<ActionView::Base:0x2556020>
In the tutorial, they explain that these two lines are transla...
I am using ruby on rails. Below given code works. However I was wondering if it can be written better.
# Usage: write 'hello world' to tmp/hello.txt file
# Util.write_to_file('hello world', 'a+', 'tmp', 'hello.txt')
def self.write_to_file(data, mode, *args)
input = args
filename = input.pop
dir = Rails.root.join(*input...
Hey all,
I have a custom route:
map.resources :user_requests, :member => {:confirm => :any}
I have two methods in my Request controller for this purpose:
def confirm
x = current_user.contact.contactable
@requests = UserRequest.find(:all, :conditions => ["location_id = ?", x]) #The results from this display in dropdown list.
end
...
I'm re-factoring a semi-successful Rails-based event registration and pledging system for a particular fundraising event for a non-profit.
The existing data structure is rather ungainly, though it captures all necessary details and relationships. I would plan to refactor this in any case, but since I've also been asked to allow for mul...
I just need some clarification on a couple of files.
My site has an admin subdomain and SSL in addition to the normal *:80 details found in the virtual hosts.
My question(s): Do I need to specify a 1) ServerName and 2) DocumentRoot in: /etc/apache2/apache2.conf?
I currently enable my site from this directory: /etc/apache2/sites-availa...
I already generated a class by "script/generate model blah blah1:string"
How would I add a "blah2:string" to the existing model? Is there a script or do I have to manually edit the database and every file?
...
As much I would like to I still don't know how to implement metaprogramming.
For views rendered from my Admin::Base controller I would like override the Rails compute_public_path located under ActionView::Helpers::AssetTagHelper, so that all my admin's layout files will be under public/admin.
There is probably a better way to this, but...
In the release notes for Rails 3.0 beta it says:
"Unobtrusive JavaScript helpers with drivers for Prototype, jQuery"
So how do I setup Rails 3 to use jQuery then? It still loads all the Prototype libraries by default.
I took this to mean that Rails 3 has built in functionality similar to the jRails plugin, but maybe I'm misunders...
Is there a more compact way to write the following code. I would like to get rid of the line that assigns the empty string when flash[:add_run_error] is nil.
unless run.save
run.errors.each do |attr, msg|
flash[:add_run_error] += '<br/>' if flash[:add_run_error]
flash[:add_run_error] = '' unless flash[:add_run_error]
...
I am still newer to Rails... I need to write a self.method on my Product model to find the next Product per position. I am showing 1 Product on a page, and want the next one in the list.
def self.next_product
product = Product. # current product.position +1
end
obviously this won't work... I am still new to writing methods. anyone?
...
I have an if statement in my Rails app. I need to do a basic "if true and !false" sort of check. The expression is defined as:
ActiveRecord::Base.connection.tables.include? 'settings' && !Settings.setting_is_set?('defaults_set')
If I put that as my expression to an if, the if will not trigger. If I run that expression in the console, ...
I have a user and a profile model. One user can have many profiles. I need to access only one information from the profiles section (viz the phone number) in my user model during the user creation process. Hence I'm trying to get it done through attr_accessible. My user.rb looks like this.
has_many :profiles
attr_accessible :handle, :em...
Given that it is well-documented how to use before_filter for a single user classification, I'm having trouble getting action-level protection for multiple user types. Let me explain:
I've got something like this...
class ApplicationController < ActionController::Base
class << self
attr_accessor :standard_actions
end
@stand...
I currently have some large strings that I would like use as test data when testing a log scraper. It would work well to have these strings in a YAML file.
I would love to refer to them while testing in a short and concise manner such as:
log_lines(:incorrect_string)
Is there anyway to do this using fixtures, or are they exclusively...
I am in the beginning stages of learning ruby and RoR.
I have a Ruby on Rails project that tracks jobs a server is running. Right now, when you manually create a new job, it announces flash[:notice] = "Created job job number #{update.id}." I would like to turn the #{update.id} into a link to the job on the job list.
The URL for goi...
I'm trying to run a Ruby on Rails project (redmine) on a VPS. It's working, but it takes quite a bit of RAM. The rails application has very light usage compared to the rest of the VPS. I have lighttpd running on the server as well.
I'm new to Ruby and know there are several ways to launch a webapp in Ruby. I'm currently just using w...
Ignoring rolerequirement with restfulauthentication method in a subdomain scope
I have created a site which utilizes subdomains and searches whether or not the user is at: subdomain.domain.com or domain.com. If the user is in subdomain.domain.com, /views/layouts/application.html.erb appears, if the user is in domain.com /views/layouts/p...
I have a problem occurred while upgrading the rails version from 1.2.3 to 2.3.4. Here is the problem.. I had updated the rails version to 2.3.4. When i tries to run the application am getting the following error:
Undefined method 'cache_template_extensions' for Actionview::Base::class.
I tried for the solution. Most of the people recom...
Assume the require_role ["alt", "student worker"], :except => [:list, :show, :index, :create] works outside of this method, what am I doing wrong here? When I call the method it works while it is a promo_site? (true), but when it is false the method fails.
def check_if_role_is_required
require_role ["alt", "student worker"], :exc...
Hi i converting rails views from erb to Haml .The issue i faced is when use the form_for the haml throws the UNEXPECTED $end error. I am sure i did the space indentation well with in form_for .......Even if i use "each do" loop is says the same error. if i revert the haml to erb it works fine.
Rails version i used : 2.3.2 & i installe...