I want to build a scalable dynamic Web Application. I have never programmed an Object Oriented language before. Or, let's just say I am completely new to programming, because the previous experiences aren't worth talking about.
I know I have a really big task ahead of me ^^ but I wanted to get into coding for the last 10 years and now t...
I have a Movie plan table:
movie_plans (id, description)
Each plan has items, which describe a sequence of movies and the duration in minutes:
movie_plan_items (id, movie_plan_id, movie_id, start_minutes, end_minutes)
A specific instance of that plan happens in:
movie_schedules (id, movie_plan_id, start_at)
However the schedule ...
The use case is simple.
I allow users to enter in an expiration field which needs to be between 1 and 15 into a form. The model takes that number and converts it into a datetime (such as adding 15 days from today) and stores it in the database.
What's the correct way to actually validate that though? Do I validate against the datetime ...
This is an extension of an earlier question. I realized, what I really want is to go to a URL /report/thisweek and it will do a .find (or named_scope) across contact_emails.date_sent where date_sent is between MONDAY and FRIDAY of the week to which Date.today belongs.
In other words, if today is THURSDAY, it will do a search for all em...
Hi,
I'm trying to get two things done after a user clicks on a link:
Delete a div
Add another element at the bottom of the page
I played with Rails link_to_remote and what I get with the code below is that the element is added before the div is deleted:
<%= link_to_remote "✓",
:url => {
:controller => :movies,
:act...
I have an interesting situation, well it's probably not that unique at all, but I'm not totally sure how to tackle it. I have a model, in this case a recipe and the user navigates to the new path /recipes/new however the situation is that I need to be able to have the user upload images and make associations to that model in the new acti...
I am very new to Ruby on Rails and was never really big on writing JavaScript, so the built in helpers were like a tiny silce of heaven.
However I have recently learned that using the helper methods creates "obtrusive javascript" so I am doing a tiny bit of refactoring to get all this messy code out of my view. I'm also using the Prototy...
I am using Devise for Rails. In the default registration process, Devise require users to type the password twice for validation. How can I disable it?
Thanks all. :)
...
hi.
I have a multiple file upload form(html5) and want to update my view as soon one of the images is transfered to my image server.
Currently I upload the files with ajax and use response_to_parent to update my upload view when all images are transfered to the image server.
Is it possible to call a Javascript function from the cont...
Hi.
I've got form for some model A, which has got few fields:
tile
description
...
colors
colors are selected from multiple select and options are ['red', 'green', 'blue', 'yellow']. User can choose colors as many as he wants. I don't think that making Color model and has_many relationship is good solution here to store colors data...
I have a model with a callback that runs after_update:
after_update :set_state
protected
def set_state
if self.valid?
self.state = 'complete'
else
self.state = 'in_progress'
end
end
But it doesn't actually save those values, why not? Regardless of if the model is valid or not it won't even write anything, even if i r...
Having a bit of difficulty finding out the proper way to mix in code that I put into the lib/ directory for Rails 2.3.5.
I have several models that require phone validation. I had at least three models that used the same code, so I wanted to keep things DRY and moved it out to the lib/ directory. I used to have code like this in each mo...
How can I translate this SQL into a named_scope? Also, I want the total comments param to be passed through a lambda.
"select users., count() as total_comments from users, comments where (users.id = comments.user_id) and (comments.public_comment = 1) and (comments.aasm_state = 'posted') and (comments.forum_user_id is null) group by user...
I need to perform a task every 5 seconds, but only when users are using the application.
As for now, I use cron that works every minute and activates a task that repeats itself every 5 seconds with sleeps between, for a minute. However, it works also when the application isn't being used.
Is there a gem that will do this kind of thing?...
I created a file so I can share a method amongst many models in lib/foo/bar_woo.rb. Inside of bar_woo.rb I defined the following:
module BarWoo
def hello
puts "hello"
end
end
Then in my model I'm doing something like:
def MyModel < ActiveRecord::Base
include Foo::BarWoo
def some_method
Foo::BarWoo.hello
...
I am trying to build a CMS using ERB. Is there a way you can give ERB code read-only access to your models? For instance, I want to be able to load any information on my models (Model.all, Model.find_by_slug, Model.find_by_name, Model.other_model.name, etc...), but I don't want to be able to change this data. Can you disable ERB from ...
It is very common in Rails for an objects_controller controller to have RESTful edit and destroy actions like so:
def edit
@object = Object.find(params[:id])
end
def destroy
@object = Object.find(params[:id])
@object.destroy
redirect_to :back
end
With an associated view that provides edit and destroy links like so:
<%= link...
Hey,
I need to implement a ruby on rails project using XML-RPC. I have no idea where to get started but I've used ruby on rails before (just never with XML-RPC). Can someone help me out on get started with this?
...
Hello I have both Rails2 and Rails3(beta 3) installed by Ruby Gems. Everything right now defaults to using Rails3. For instance rails myproject will create a new Rails3 template. How do I override this so everything goes to Rails2?
...
Not sure why I'm getting this, but I just installed RVM, the new Ruby 1.9, and reinstalled a bunch of gems, and I get this
/Users/johnsmith/.rvm/rubies/ruby-1.9.1-p378/bin/gem:4: warning: Insecure world writable dir /opt/local/bin in PATH, mode 040777
Everything still runs otherwise, but I was wondering if there was a way I could get ...