Hey there,
I'm currently learning RoR and I've got the following problem:
My Model, "DataFile", has a bunch of fields which I'd like to set from outside the Model, e.g.
file = DataFile.new
file.owner = 123
Now, as far as I know, I'd have to place an "attr_accessor :field" in my model, for every field that I'd like to modify from ou...
Ok so I have acl9 in place and functioning, and my app structure thus far:
Regions (which have) Locations (which have sales). Sales aren't important, basically just posts which will show on each location.
I also have Users, which integrated with acl9 can be restricted and allowed based on role.
What i need to to do is create companies...
Is there a way to determine what version of Ruby is running from within Rails (either on the web or through script/console)? I have Ruby 1.8.6 installed but I've also installed Ruby Enterprise Edition 1.8.7-20090928 and want to ensure that it's using the right installation.
...
I really need help with Rubygems (that's the package manager for ruby). Since I'm behind a proxy, I've given up all hope of it working automatically, so I had to download a lot of packages manually and install them for rails to install. Now, I'm getting an error message:
Rails requires RubyGems >= 1.3.2 (...)
Once again, I manually dow...
I have a 1GB slice from slicehost and I have 4 projects running on that box. All 4 applications are ruby on rails application. I was wondering what is the best way to ensure that log files are rotated.
I would prefer to have 4 different log files one for each app rather than having one big log file for all 4 applications.
I am running...
I'm trying to add a "current" class to the following set of links based on if there is an "order" param in the URL. (ie. example.com/photos?order=views). I need some help refactoring this so it's not so burly.
<% unless params[:order] != 'created_at' %>
<%= link_to "Recently Posted", photos_path, :class => 'current' %>
<% else %>
...
I have a route in my code that looks like this:
map.app 'applications/:title_header', :controller => 'apps', :action => 'show'
I also changed my show method in the controller to be like this:
@app = App.find_by_title_header(params[:title_header])
If I type in applications/title things work fine. If I type in applications/1 (valid I...
Hello,
I am relatively new to ruby on rails, so this question might be easy. Rails does a lot of magic and I am not sure where to look up such things, because I don't know which part of the framework is to blame.
I basically did the authlogic_example and fiddled around with the code afterwards.
My routes.rb looks like this
map.root ...
I have a
periodically_call_remote
that I want to fire right away (as if the code was present without the setTimeout) as well as call periodically. Is there a nice way to do this use PCR, or do I have to roll my own?
I'm using jQuery/jRails if it helps.
...
I have a user model with a HABTM relationship to groups. I do not want a user to be able to be in more than 5 groups, so would like to validate the length of the HABTM relationship.
On the edit user page I have a list of checkboxes where the user can select the groups they want to be in (I'm using formtastic for the form).
In my users...
I am writing some performance tests and I want the user to be logged
in:
class CompaniesTest < ActionController::PerformanceTest
fixtures :all
def setup
login_as(:cyrille)
end
def test_homepage
get '/'
end
end
The problem is: how should I implement login_as?
I tried:
private
def login_as(user)
@...
I'm trying to do something I thought easy and natural but I'm struggling..
On the homepage of my website, I want a select containing a list of users. After selecting a user and clicking on a button, it should go to the show action of the User controller page.
I searched and found differents answers that I don't find very elegant:
usi...
I have a couple of pre-existing applications which I need to run in "one" app. One is the application I want to use for authentication etc, whilst the other is another app that contains all of the business logic.
Both apps have pre-existing authentication, and both have fairly complex user models.
Is it possible to easily combine thes...
hi all
I have been trying to do this for ages and can seem to grasp it. hope someone can help ?
i have a 'message' model that has many through 'distribute' relationship to a 'contact_detail' model.
basically a message can have many contacts associated with it and a contact can have many messages.
I can get this to work and save it ...
I'm writing an app that has a "wizard" type input section. Think MS Windows Installers.
I'm having a hard time figuring out how the most RESTful way to do this with rails. I can make it happen in a non-restful way (already did for version 1 of the app), but I'm trying to be a little more idiomatic this time around.
Here's the situati...
Hi guys,
Rails question. The default behavior for error validation is to fieldWithError-styled div around the input field like the following
<div class="type-text" id="pre_negotiation_value_div">
<label for="contract_budget_holder">Budget Holder</label>
<div class="fieldWithErrors">
<input id="contract_budget_holder"name="contract[bud...
I installed the ruby gem for mysql and it looks like it installed correctly except for the documentation.
I reviewed http://www.rhinocerus.net/forum/lang-ruby/587057-gem-install-mysql-returns-list-no-definition-xyz.html but it didn't help.
Some notes, I am running on a 32-bit intel processor. Mac os x 10.6.1
Mac-Shaun:usr shaun$ s...
If I have my website logically split into accounts (eg. acme.mywebsite.com, xyz.mywebsite.com), how can I implement act-as-taggable-on-steroids and have the tags scoped by the current account ?
To give little more details, if I am accessing acme I don't want to see tags from xyz subdomain.
I have looked into act-as-taggable-on, but the...
In an ActiveRecord model, is it considered best practice/necessary to use validates_presence_of when also using validates_length_of?
For example:
class Company < ActiveRecord::Base
validates_presence_of :name
validates_length_of :name, :in => 5..30
end
To me, it seems redundant. Having a length between 5 and 30 means that the a...
I did some stuff to have to_param return a perma-url so I'd have seo friendly links. Upon creation and update it will generate and return the perma-url in a to_param method that I put in the model. However this causing me some grief in other areas. I have a form that looks like this:
<% @apps.each do |app| %>
<% fields_for "[id][...