I have an Entry model which has many Tags. Tags are added to an entry by typing them into a textbox on my form, via a tag_names virtual attribute. Before validation on the Entry model, the tag_names string is converted into actual Tag objects using find_or_create_by_name. The Tag model also has validation to make sure the tag name matche...
I'm trying to split up a web site into two sections. One which should use the application layout and one that should use the admin layout. In my application.rb I created a function as follows:
def admin_layout
if current_user.is_able_to('siteadmin')
render :layout => 'admin'
else
render :layout => 'application'
end
end
...
I am trying to create a validation that checks to make sure a domain/url is valid for example "test.com"
def valid_domain_name?
domain_name = domain.split(".")
name = /(?:[A-Z0-9\-])+/.match(domain_name[0]).nil?
tld = /(?:[A-Z]{2}|aero|ag|asia|at|be|biz|ca|cc|cn|com|de|edu|eu|fm|gov|gs|jobs|jp|in|info|me|mil|mobi|museum|ms|name|ne...
See comments for updates.
I've been struggling to get a clear and straight-forward answer on this one, I'm hoping this time I'll get it! :D
I definitely have a lot to learn still with Rails, however I do understand the problem I'm facing and would really appreciate additional help.
I have a model called "Task".
I have an abstract mode...
Hi All,
I'm rendering a partial in a collection like this :
<%= render :partial => 'issues/issue', :collection => @issues %>
Inside the partial, I want to render a element unless it's the last in the collection. I could of course, render the partial like this
<%= render :partial => 'issues/issue', :collection => @issues, :locals =>...
Hi,
I'm using delayed_job to run jobs, with new jobs being added every minute by a cronjob.
Currently I have an issue where the rake jobs:work task, currently started with 'nohup rake jobs:work &' manually, is randomly exiting.
While God seems to be a solution to some people, the extra memory overhead is rather annoying and I'd prefer...
I have a pretty simple HABTM set of models
class Tag < ActiveRecord::Base
has_and_belongs_to_many :posts
end
class Post < ActiveRecord::Base
has_and_belongs_to_many :tags
def tags= (tag_list)
self.tags.clear
tag_list.strip.split(' ').each do
self.tags.build(:name => tag)
end
end
end
Now...
I have a structure something like this:
class User
has_many :dongles
has_many :licences, :through => :dongles
end
class Dongle
has_many :licences
belongs_to :user
end
class Licence
belongs_to :dongle
end
However, time passes and the user eventually gets multiple licences for each dongle. Reasonably, the app wants to summa...
Hi all,
I'm creating CMS where created and updated posts have to be moderated. Ie. user Bill updates post - new content is stored somewhere in database. Unless cms-admin accepts Bill's post visitors should see post content before Bill's update. When cms-admin accepts new post content visitors see fresh version.
I think about using acts...
Hello,
How do I include functions from the application controller in a config.after_initialize block?
enviroment/development.rb
...
config.after_initialize do
require 'application' unless Object.const_defined?(:ApplicationController)
LoggedExceptionsController.class_eval do
access_control do
allow :admin
end
...
Hi there, I have a basic has_many :through relationship that is bi-directional:
calendars have many calendar_calendar_events
calendars have many events through calendar_calendar_events
events have many calendar_calendar_events
events have many calendars through calendar_calendar_events
I'm wanting to assign calendars to an event wit...
I've created a small non-profit Rails application which I want to make available in the next weeks.
Because of my small budget I cannot be picky about the hoster. The one I found provides only certain Linux distributions.
CentOS 5.2
Debian 4.0
openSUSE 10.3
Those are virtual servers with full root access.
EDIT: I don't have exper...
I have installed Ruby CAS server and my application is a simple Restful Authentication User Management Application , i would to like experiment my application by providing a Central Authentication for my User Management Application , i am using Restful authentication plugin for this , which act as the Ruby CAS client .
Does Ruby CAS se...
Hi guys,
I'd like some advice on how I should synchronize a list of email addresses on 11k users against an external mailing list program, in this case http://www.mailchimp.com/api/1.2/listbatchsubscribe.func.php" title="Mailchimp API"">Mailchimp.
Normally the way I'd so this is simply to have an :after_save callback, to send a single ...
Hello,
I have 2 equal-access models: Users and Categories
Each of these should have the standard-actions: index, new, create, edit, update and destroy
But where do I integrate the associations, when I want to create an association between this two models?
Do I have to write 2 times nearly the same code:
class UsersController << Appl...
I am currently trying to round off a float number but i get an error message like: undefined method round_to for float 16.666667.. and my code for rounding off is
option = [keys[count], (((o.poll_votes.count.to_f)/@general_poll.poll_votes.count.to_f)*100).round_to(1)]
And what suprises me the most is that i have used this code a...
Mongrel, Thin, Webrick, Passenger... Wich one is the most effective solution to put a RoR application in a production environment? Which one is the most flexible, and easier to install and setup under Windows for development environment?
...
I want to create a form for making a reservation for borrowed items. A reservation consists of pick up time, return time and items the reserver wants to borrow and their amounts. For example, I might want to reserve three plates, three knives and three forks for the rest of the week.
In the form, I want to do an AJAX validation that che...
Hi,
I've installed Ruby 1.9.1 alongside Ruby 1.8.6 on my Mac OS X Leopard using the prefix and program-suffix options so that I can run Ruby 1.9 stuff by issuing ruby19, irb19, gem19, etc. commands.
I've installed the corresponding gems and can run rake19 spec to execute my rspec tests but when I run autospec I get:
loading autotes...
Hi all,
I've been looking into searching plugins/gems for Rails. Most of the articles compare Ferret (Lucene) to Ultrasphinx or possibly Thinking Sphinx, but none that talk about SearchLogic. Does anyone have any clues as to how that one compares? What do you use, and how does it perform?
...