I have a few Rails 3 apps deployed to Heroku that need to share some business logic. Apparently, although Heroku's Bundler support is pretty solid, it can't yet pull from a private Github repo. So instead I'm building a couple of gems, vendoring them into each app, checking them into git, and pushing them up with the rest of my code.
Th...
I like having separate classes, one class represents the entity, and that a separate DAO (database access object).
Is this possible with rails and active record?
...
Hoping someone can clarify the differences between a belongs_to and a has_one.
Reading the rails guide hasn't helped me.
...
I am using Rails 3.0.
I have an Orders table with customer-id and orderPrice. A separate table contains information about customers. I want to get the following information in single database query and I am not sure if this is possible.
I want to get a hash of customer-names with the total amount of their order. {Customer.Name => sum(o...
I have a note field of string type in one of my models in my sqlite3 database, but I realized that I needed to store more text than string would allow.
I just ran a migration changing the type of the field from string to text. Looking at my database, it says that the type is now text(255), whereas before it was varchar(255).
What doe...
Hi,
I have the following code in my User model:
attr_protected :email
I'm trying to create a new user object, but I get a mass assignment protected error with the following code.
user = User.new(
:first_name => signup.first_name,
:last_name => signup.last_name,
:email => signup.email,
:birthday => signup.birthday,
...
Hello, I'm interested in learning how to implement a News Feed / Activity Feed on a web app for multiple models like Books, Authors, Comments, etc...
Any recommendations from the group? Gems/Plugins, or experience personally or from others on the best/smartest way to proceed?
Thanks!
...
I have the following model: (goal is to create a news feed / activity feed for my app).
Activity:
id.int | user_id.int | item_type.string | item_id.id | created.timestamp | data.string
With the intent that I can create records like:
{id:1, userId:1, item_type:Photo, item_id:33, time:2008-10-15 12:00:00, data:{photoName:A trip to the...
Is it possible to integrate Disqus with my existing authentication solution?
I am developing a app using RoR and authologic!
...
My page urls are like '/about' and my city urls are like '/san-francisco'. There is no overlap. How can I get the following routes to play nice?
get '/:city_slug', :to => 'cities#show', :as => 'city'
get ':action', :controller => "site", :action => 'show'
...
Can Rails automatically parse datetime recieved from form text_field?
<div class="field">
<%= f.label :created_at %><br />
<%= f.textfield :created_at %>
</div>
params[:product][:updated_at].yesterday
Currently i get following error:
undefined method `yesterday' for "2010-04-28 03:37:00 UTC":String
...
I want to find all Contacts where the value of their :has_one relationship to :contact_status does not have a value (does that mean nil?)
I created an alias_attribute :status, :status_contact
Can I do something along the lines of:
contacts = Contact.find(:all, :conditions => {:contact_status => nil }, :include => {:status_contact} )...
Howdy.
I'd like the cycle method to take an array of values which I compile on the fly, but it seems to be interpreting it not as I'd have hoped.
(In this example it's a static array, but I want it to work so that I can use arrays that are constructed variably)
- some_array = ['one', 'two', 'three']
- colors.each do |color|
%a{ :nam...
Hi All, I have done a validation check in my form to check for email,username and firstname...here is the code
class User < ActiveRecord::Base
validates_presence_of :email, :firstname, :username
validates_format_of :email,
:with => /[-!#$&'*+\/=?`{|}~.\w]+@[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])*(\.[a-zA-Z0-9...
Hi,
i've found this tutorial in the internet to render flash object (OpenFlashChart) as an image in PHP.
http://teethgrinder.co.uk/open-flash-chart-2/save-image-js.php
Unfortunately i've tried to do the very same thing but failed to do so, becauset of different implementation procedure in Rails.
Does anyone here knows how to render o...
I am developing a small rails app to serve fonts to other sites
say a request http://url/fonts/fontname will return woff,eot or ttf font based on the browser type.
This app is working fine in my localhost but not in other ip... I know the problem is something to do with Cross-Origin Resource Sharing restriction but don't know how to so...
Hi All,
I can run the following command from my rails app:
Hash.from_xml(%x{curl -d "admin=true" http://localhost:8888} ) rescue nil
now I want to replace the "admin=true" by a variable
If I have x = "admin=true"
how can I then write the above command?
Thanks a lot
...
Using
http://github.com/archiloque/rest-client
When posting a file using this line, the content type is set as
Content-Type: multipart/form-data; boundary=301405
in the header, by default.
RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb')
I tried this and it still sets the header multipart/form-data.
RestC...
I am facing such problem in which 's is present in data. while searching it does not shows data. I wanna remove SQL injection issue
Code ::
@search_condition = ""
if !search_text.nil?
search_field = search_text.split("-")
@search_condition = "( address_books.organization_name like '#{search_text}%' or...
I am trying to post an XML to an API which returns me an XML. I successfully did that by executing a simple CURL command
curl "http://my.server.com/api/identity/emails_from_ids"
--proxy dvaic.snv.fex:80 -d "<users><id>3434</id></users>"
-X POST -H 'Content-Type: application/xml' -u admin:admin
The above command executes successfull...