[Rails] Where to put this code?
I have a user1 and when another registered user2 sees the profile of user1, has some buttons on it: ['add as friend', 'give me your number', 'give me your email', 'ask her out', 'view photos']. The 1,2,3,4 are POST, with AJAX. Now, i have to make a new controller named 'ProfileActionsController' or i should put this code in the 'UsersController'?
or maybe a another posiibility? thanks ;)
My database has a datetime field, and I want to be able to create new entries. Obviously the Rails datetime_select helper isn't the most user friendly thing to have in your form.
I'd rather have a text field for the datetime (or one for the date, and one for the time) and interpret the inputs like PHP strtotime can.
I might just be searching the wrong keywords. Surely this has been discussed in great depth somewhere.
Thanks
:0)
Hi everyone,
I have a Transaction for a batch insert/update block and all of sudden it stopped working.
The are no errors or exception risen and it seems like Rails stops just before the end of the Transaction blog so the methods does not return.
I restarted both MySQL and the system but still.
How do I configure RubyonRails to output standard HTML code instead of XHTML when using helpers (form, javascript, css, etc.)?
I don't want to have the slash at the end:
<input name="email" type="text" />
Hi everyone,
I am currently working on a project and i would like my users to be able to backup/restore theirs accounts.
I am looking for a rails plugin/gem that would easily do that, ie :
current_user.backup()
= backup_file
current_user.restore(backup_file)
= database import/replace
I don't know if my question is very clear, but i would like to backup every user's related object (posts, comments, etc) and to be able to restore them from a backup file.
Thanks per advance,
Cédric.
In my rails app I have defined the routes so users can access records like http://mydomain.com/qwe2
But if they type a wrong "qwe2" they get a 500 page. I think a 404 would be more appropriate.
How can I change the error page that is shown? Thanks
Has anyone managed to get HolyGrail (http://github.com/mynyml/holygrail) to work with RSpec. It is currently TestCase centric, but I was hoping for an easy way to extend into RSpec/Rails
The following situation:
I have a poi model, which has many pictures (1:n). I want to recalculate the counter_cache column, because the values are inconsistent.
I've tried to iterate within ruby over each record, but this takes much too long and quits sometimes with some "segmentation fault" bugs.
So i wonder, if its possible to do this with a raw sql query?
When I execute a Rails unit test from the command line (as suggested here) such as
ruby unit/test_model.rb
...I get this error:
No such file or directory - .../test/config/database.yml (Errno::ENOENT)
Am I doing something wrong? Or is there a workaround?
I've noticed that pagination gems like mislav-will_paginate are quite popular. Is this because Rails does not have a built-in pagination solution or because the built-in solution is not very good?
I am trying to get put out a simple site, which would pool the database every few seconds and update the information on the page dynamicly, when theres something new inserted.
I am farily new to ruby, but I understand the whole concept of RJS, link_to_function and soforth. The question is, what is the best way how to implement some kind of simple loop, which would run after the page is loaded and update the DOM if there is something new to display.
Thanks in advance for any tips!
i'm looking for a rails plugin for open id authentication.
I'm using restful-authentication
Can you tip me any plugin?
Do you know any tutorials for using these plugins?
thanks
Hi everyone,
SELECT * FROM jobs WHERE (SELECT DISTINCT jobs.* FROM jobs, job_requests WHERE (jobs.user_id = 1) OR (job_requests.user_id = 1 AND job_requests.job_id = jobs.id))
This sql gives me Mysql::Error: Operand should contain 1 column(s). If i execute the select from the where clause it works SELECT DISTINCT jobs.* FROM jobs, job_requests WHERE (jobs.user_id = 1) OR (job_requests.user_id = 1 AND job_requests.job_id = jobs.id)
Could somebody explain me why? This query is generated by rails activerecord so the main select is needed.
The name pretty much says it all. Does anyone know how to accomplish functional testing when you are not using migrations in Rails? I'd be open to any advice or third party libraries (if there are any). I thought of creating my own plugin to address this but it seems like a pretty big task and would rather not do this unless necessary.
Thanks in advance.
I am working with Rails 2.2.
The required behaviour is as follows:
I have a link(with a ajax link embedded)
xyz.com/admin#page1
When I go to the above page, I should be redirected to the login page, if I am not logged in.
After I log in, I should be taken back to
xyz.com/admin#page1
For this I need to store the url in session when I visit any page.
The problem is that when I do request.uri, I get
xyz.com/admin
But I want to store
xyz.com/admin#page1
Regards,
Pankaj
Hi Everyone,
A follow on from this questions:
http://stackoverflow.com/questions/3032598/rails-created-at-on-display-if-today
Is it possible to output the word TODAY rather than the date when using the following helper?
def created_today k
k.created_at if k.created_at.to_date == Date.today
end
<%=h created_today(k) %>
Thanks,
Danny
Hello, World..
I'm currently building a website for an awesome youth church we run (shameless plug!)..
Anywho at the moment we have a static countdown page http://mybase.co , and were having a massive launch this weekend and the site needs to go live when we launch,
it's a rails app..
How would you recommend scheduling it going live?
having a cron job and an apache a2en?
or is there a better way?
Thanks
Daniel
I am on the rubyonrails application and trying to embed the code for js , added the whole code for embedding in Text box , But when i copy paste in other blogs where embed is poss , i am not getting the full js work , the code is given below
<%= text_field_tag "text","
script src=\"/public/javascripts/calendarview.js\"
script src=\"/public/javascripts/calendarview_init.js\"
link rel=\"stylesheet\" href=\"/public/stylesheets/calendarview.css\"
link rel=\"stylesheet\" href=\"/public/stylesheets/calendarview_init.css\"
",:size = 40
%
I have just removed < for let it be seen in the coding window
PLease help if poss
List item
Background Job gets mentioned a lot but all the tutorials I've seen seem to indicate that its for queuing jobs which are created by some external event such as a user clicking "Send mail".
But what about when you have code that needs to scheduled to run every 30 seconds to listen for new messages from twitter?
Normally rake is recommended for set in stone schedules but it inst so efficient for frequent jobs as it has to to load the entire rails app each time.
Can anyone recommend anything for this situation?
I'm using clearance (http://wiki.github.com/thoughtbot/clearance) for authentication in my rails app. But I'm trying to figure out how to grab the user's ID in a view after logging in.
Any ideas?
I need to push my rails code into stating environment from github. And then deploy this app into engineyard in staging environment. Could some please give me step I need follow
Is it normal for my test suite to take 5 seconds just to launch? Even when running an empty suite it still takes this long. Is it because it's firing up a new instance of railson each run? If so, is there anyway to keep it persistent?
I'm using Test::Unit with Shoulda.