I am deploying an app on Heroku. Though the experience of deploying is good but I am having pain in fixing stuff.
Very first thing is that autoincrement IDs are all messed up between heroku db and my db. So before deploy I have to delete all data from my local app and then push my DB to heroku. If I don't do that then while trying to a...
How do I use migrations to create a postgres sequence?
I have created a migrations file with the following executes:
execute 'CREATE SEQUENCE "ServiceAvailability_ID_seq";'
execute <<-SQL
ALTER TABLE "ServiceAvailability"
ALTER COLUMN "ID" set DEFAULT NEXTVAL("ServiceAvailability_ID_seq")
SQL
However, when running rake db:migr...
I'm attempting to parse Media RSS feeds that contain media:* elements, but it seems as though all of the standard RSS parsing libraries for Ruby only support enclosures, not MRSS elements.
I've tried:
SimpleRSS
RSS::Parser
Syndication:RSS::Parser
Ideally, I'd like something that makes it simple to extract elements such as media:th...
Hi,
I add this line in my routes.rb file
map.connect ':controller/:action/:id/:title', :controller => "recipes"
thinking that I am adding the recipe title at the end of the URL and this would only apply to the recipe controller. I have also declared a resource at the beginning of the file like this
map.resources :recipes
The follo...
你好,
When a column in mysql table is typed :text, how is this then treated in Ruby.
In other words, what is the class?
Is it a string?
...
Hi,
I'm creating a little social network in Rails, where people can add eachother as a friend. I have created a model called 'user', which contains, e-mail, strong md5 hash with salt of password etc...
My question is: how do I create something like an option to add another user as a friend. Is it possible to have something like has_man...
From the Rails Guide on debugging, I found that I can customize output to my log files using this simple method:
logger.debug "Person attributes hash: #{@person.attributes.inspect}"
I decided use this to track how a variable changes and goes through flow control.
I would like to be able to see the line number of my code where logger#...
For an answer model I want to save different types of answer (e.g.decimal, string, text, ...) in different tables.
Polymorphic seems the way to go, but how can I receive the users answers from a nested form using fields_for? I now in advance, what type is asked for, but how do I tell in the controller in which table the answer should be...
Hello guys, I'm building currently one Rails app and I'd like to stick to all those fancy things like REST and Resources, but I'd like to customise my routes a little. I want my GET route to be little more verbose - the app I'm creating is a simple blog, so instead of GET /posts/1 I'd prefer something like GET /posts/1-my-first-post.
An...
Hello,
I'm creating a Rails app, and I have a model called User. In this model I have a boolean value called isagirl. A user must specify if it is a girl or not, which is done by two radio buttons. In my model I have this:
validates_presence_of :isagirl, :message => "You must be either a Boy or a Girl. If not, please contact us."
How...
I'm trying to implement a UI feature for a listings page where the user can change the order of the records they have created.
I'd assume one way to do it would be to store a position field with some kind of editable auto-increment rule; The position values of rows could then be swapped as the user raises or the lowers the position. How...
I do Ruby on Rails development pretty much exclusively. I currently develop in OS X using TextMate. I have a virtual machine running to emulate as closely as possible the environment my app will be deployed into, and I mount the code on a Samba share into OS X from the VM guest. From there I open with TextMate and code away.
I'm beginni...
I have a controller posts:
www.mydomain.com/posts/123-hello
Please bear in mind that the 123 is unique for each post but is not the correlative id (post.permalink)
I want to access the posts through addresses like:
www.mydomain.com/is/123-hello
not
www.mydomain.com/posts/123-hello
I have a to_param in my Post model to construct the "...
I'm successfully running subdomains on my mac OSX as outlined by Robby on Rails. I'd like to follow the example code below but I have no idea where to start. How do you edit a DNS setup? Do I need to have a dedicated virtual host to do this? Right now I have a standard (crappy) Dreamhost shared hosting. If I go with a DVH, is Media Templ...
I am redirecting from one action "receive" to other "show" using
redirect_to @post
I need to know if the visitor was redirected in the view for show
Can I store a variable @flag in receive and use it in "show" after the redirect? I couldn't.
Is there a way to pass a parameter without showing it in the URL?
Thanks in advance.
...
I have a constant that is only used in views, but it's used in different ways in different places. It's an array of option names, and is used for select boxes, but I also use this in other views to see if strings are found in this array, and respond accordingly.
What's the best way to handle this to keep DRY?
I initially created a con...
In associations between different models, one can avoid setting foreign key IDs directly by using fixture names as in this answer. What about self-referencing associations, such as when using acts_as_tree? Trying this:
# categories.yml
forsale:
name: For Sale
parent_id: nil
books:
name: Books
parent: forsale
I get this error:...
I've got users who are members of groups through a membership join table, and one of the attributes of that join table is "administrator". I'm trying to do a check inside of a group's member view, looping through each member to see if they are an administrator.
In the view I tried the following:
for user in @group.users
if user.admin...
Hello,
I'm not exactly sure how to frame this question so I'll just go for it. I am recently returning to rails after a hiatus and I am building a social networking style application. Basically I'd like to do what twitter does and have each persons profile page be found at "http://www.url.com/username" and while I have managed to get th...
There is a post on http://kenai.com/ from Oracle's Ted Farrell which has an interesting statement:
We are in the process of migrating java.net to the kenai technology.
Does this mean java.net will be powered by Jruby on rails??
...