I have been tasked with developing a new retail e-commerce storefront for my current job, and I am considering tackling it with RoR to A) Build a "real" project with my limited Rails knowledge, and B) Give management quick turnaround and feedback (they are wanting to get this done ASAP and their deadlines are rather unrealistic - I'm tal...
So I have some models set up that can each have a comment. I have it set up using has_many_polymorphs, but I'm starting to run into some issues where it's not working how I think it should.
For example:
class Project < ActiveRecord::Base
end
class Message < ActiveRecord::Base
has_many_polymorphs :consumers,
:from => [:projects,...
I'm following this tutorial (seems good) for Rails. After I run
ruby script/generate scaffold Post
then this link works in one of the erb files:
<%= link_to "My Blog", posts_path %>
WHY? I've looked for "posts_path" in the whole app and it's nowhere to be found. On the other hand, this
<%= link_to "My Blog", home_path %>
does no...
Hi there,
I am going to switching SSL onto a Rails site of mine pretty soon and was wondering if anyone has thoughts or suggestions as to who is the best provider?
Does anyone have any happy stories or horror regarding certain vendors??
Thanks
Kent
...
How do you pass parameters in a URL? I'm trying to design a login system similar to Twitter's. Notice how you can either login to the main page of www.twitter.com or you can go directly to customised pages such as www.twitter.com/lancearmstrong and www.twitter.com/rails . That's exactly what I need for my project. Thanks.
...
I have a collection of people that is paginated with will_paginate
@people = Person.paginate :page => params[:page],
:limit => 10,
:conditions => ['company_id = ? ' , @company.id ]
The people are shown on the company/view page and rendered with a partial. Note that the partial is in the views of 'people'
<%= ...
How do a I create a validator, which has these simple rules. An expression is valid if
it must start with a letter
it must end with a letter
it can contain a dash (minus sign), but not at start or end of the expression
...
So I'm learning Rails and I decided to check out my cheap hosting options on GoDaddy, and their versions look like this. Are all the GEMs relevant in a normal Rails app (defining that liberally), or is just the Rails version? My guess is that is would be actionpack and rails, perhaps?
If it is just the Rails version, GoDaddy is using 1....
What is the purpose of the RAILS_GEM_VERSION setting in config/environment.rb? Is it supposed to stop your app from running under an unexpected version of Rails?
I just keep Rails updated to the latest release on my laptop and in production. Since I do that, can I comment out RAILS_GEM_VERSION or should I set it for some reason?
...
I am writing an app which - similarly to many apps out there - is 90% regular CRUD things and 10% "juice", where we need nasty business logic and more flexibility and customization.
Regarding this 90%, I was trying to stick to the DRY principle as much as I can. As long as controllers go, I have found resource_controller to really work,...
I'm attempting to post a random testimonial on each page of a site. I started off by using an application helper like so:
module ApplicationHelper
def random_testimonial
@random_testimonial = Testimonial.find(:first, :offset => rand(Testimonial.count))
end
end
In my view, I can reference the method but it's being called on ...
I know about persisting the email into the db and then letting some periodical job handle the actual sending.
I know that ar_mailer gem does this.
Are there any other approaches? Are there better alternatives?
Simply, What is the best way to handle sending many emails in Rails?
...
I checked out both of these previously-asked questions, and they're a help but not a full solution for my case.
Essentially I need to validate a user-submitted URL from a form. I've started by validating that it begins with http://, https://, or ftp:// :
class Link < ActiveRecord::Base
validates_format_of [:link1, :link2, :link3,
...
I'm working on a site where I'd like to cycle images, similar to a slideshow, while the user is on the page. I've searched around and haven't been able to find a lead.
Has anyone done this with Rails and the Javascript frameworks it supports?
...
I have an existing app that has many, many models. I'd like to log the IP address of the user that created them with the primary purpose being a way to help weed out spammers or other abusive users (if I don't know what IP address(es) they are using, I can't block it). I would need to keep track of these over time as users may access fro...
For a RoR installation, is there any way to run rake commands without root access?
To put it another way, is there any way to get db:create and db:migrate to be run without root access (perhaps automatically or something)? Or can I run rake commands from a RoR controller?
...
So I have two nested partials with calls to insert_html. Basically each team has multiple players and I have an add player button and an add team button which each call a partial with the following helpers
module TeamsHelper
def add_team_link(name)
link_to_function name do |page|
page.insert_html :bottom, :teams, :parti...
OK, as is often the case, I have a controller action in my app that is protected from unauthorized access by a before_filter. The only thing is that I need to redirect this action if another condition is true:
class Payment < ApplicationController
before_filter login_required
def new
redirect_to some_other_path if @order.is_fre...
Sorry for the slightly noobish question, as I am writing my first rails app. I get the idea of the layout view, but if you are using them, is there any way to include a view specific js or css file? For example, I have layouts/products.html.erb, and for products/edit.html.erb I want products_edit.css, but I don't want that css for all pr...
Is there a way that I can get a list of the models that a particular model belongs to in Rails?
For example:
class Project < ActiveRecord::Base
has_one :status
...
end
class Task < ActiveRecord::Base
has_one :status
...
end
class Status < ActiveRecord::Base
belongs_to :project
belongs_to :task
# this is where I want to...