Is it possible to send SMS in india using rails applcations? If so, can you provide an example?
I checked for the clickatell but I think it works only in Australia or the UK.
Hi,
I've a file in the config directory, let's say my_policy.txt.
I want to use the content of that file in my controller like a simple string.
@policy = #content of /config/my_policy.txt
How to achieve that goal, does rails provide it's own way to do that?
Thanks
In Rails, when I want to find by a user given value and avoid SQL injection (escape apostrophes and the like) I can do something like this:
Post.all(:conditions => ['title = ?', params[:title]])
I know that an unsafe way of doing this (possible SQL injection) is this:
Post.all(:conditions => "title = #{params[:title]}")
My question is, does the following method prevent SQL injection or not?
Post.all(:conditions => {:title => params[:title]})
Hi,
In Rails is there a way to get the URL to the image (going through the assets_host) and just return the URL of the image? I want to use assets_host data in my Javascript, but I just need to insert the URL into the JS, not the whole image_tag.
Thank you in advance!
Dear experts,
is there any existing rails helper to create a valid URL?
Specifically, I am generating a Web URL with some parameters that having special character (for e.g space i need to convert into + , and many others special characters).
http://domain.name?param1=ABC+DEF¶m2=GHI
Thanks.
I have a simple blogging functionality in my Rails 3 app. I am trying to add commenting to each post. The BlogComment model has a property, blog_post_id, to be able to find the corresponding comments for each post. I already setup my associations in the model, I also nested BlogComments under BlogPost in the routes file.
However, I can't figure out how to give each BlogPost access to its respective comments through the controller so that they can be shown later in the view.
I am noting this strange behavior where one of my fields -- receive_empresa_test_info -- has worked fine though it's always been referred to as receive_empresa_info. In Functional Tests, though, the real field name is receive_empresa_test_info. What is going on here? Might this be some part of the Rails environment that I'm missing during testing?
I have an application created with PhoneGap and Backbone. I upload a file as JSon and my server receive data like this :
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...
I'm trying to write the file like this :
File.open("#{Rails.root}/public/images/#{self.id}.jpg", "w+") do |f|
f.write(data)
end
It's not working and I don't know what to do. When I'm trying to open the file I have this message "Not a JPEG file: starts with 0x64 0x61".
Do you have a solution?
Hey,
I'm looking for a way to use something similar to link_to_unless_current but for sub URLs, so for instance for both these URLs:
/entity_name/
/entity_name/123
it will not result as a link. How can I achieve that in Rails?
While moving from php to rails (Means procedural language to Object oriented language), what are the various things you should keep in mind.
How to think in world of object oriented programming?
What are thinks i should kept in mind before starting the things. Any tips?
I'm trying to use the google_search ruby library (code follows) but it complains that 'cattr_accessor is an undefined method' - any ideas why this might be or how I could fix it?
require 'rubygems'
require 'google_search'
GoogleSearch.web :q => "pink floyd"
Hi,
I have a store model that has many products with a has_many :through relationship.
I have this working with accepts_nested_attributes, but the result is that rails is making duplicate associates.
I don't have anything special going on it is a very simple app.
Any ideas on why duplicates associates are getting created?
I'm using the facebooker plugin in rails to let users sign up through facebook connect. the application uses iframe. Now when certain things occur,how can I send notifications to application users from the application through facebook.
I'm new to rails and was trying out the scaffold command - the following scaffold runs and works when I view it via web brick
script/generate book title:string
the following fails - gives me a weird route error
script/generate application name:string
the following works
script/generate app name:string
can anyone shed some light on this? Is 'application' a reserved word?
I am looking to create a rails route that is capable of accepting requests using a regular expression. Specifically, I need optional paths. As an example:
"(/first)?(/second)?"
Would match:
/first
/second
/first/second
But not:
/second/first
Is this possible? Thanks.
How do I drop selected tables in Rails? I want to drop all tables from a database with a given prefix. PHPMyAdmin would be very useful at this point.
Thanks
Is there a standard way to check if a view layout exists from within a Controller in Rails? I'm trying to allow the user to determine the layout, but it needs to exist first.
I'm trying to use http://ls1.bigseapreview.com as a domain for a Rails project. The problem is it doesn't seem to be correctly mapping any routing apart from the home page.
I have added /about but you can see that you will just get a 404, but it works locally.
What do I have to do to fix this?
Hi,
is it possible to have the controller value in a rails named route as a parameter, which I can pass at runtime to direct the call to the proper controller?
e.g.
map.ride 'ride' ,:controller = {some-way-of-specifying-a-parameter}, :action = 'ride'
then at runtime, I want to pass the controller name to which this call should be going. My actions are doing different things depending to which controller the call gets sent.
thanks
I have a before_save that calculates a percentage that needs to include the object that is being updated. Is there a one-liner in Rails that takes care of this?
for example and this is totally made up:
Object.find(:all, :include => :updated_object)
Currently I'm sending the object that is getting updated to the definition that calculates the percentage and that works but it's making things messy.
While moving from php to rails (Means procedural language to Object oriented language), what are the various things you should keep in mind.
How to think in world of object oriented programming?
What are thinks i should kept in mind before starting the things. Any tips?
Rails: i have a class method and i want to modify something of the instance
something like this:
class Test < Main
template :box
def test
# here I want to access the template name, that is box
end
end
class Main
def initialize
end
def self.template(name)
# here I have to save somehow the template name
# remember is not an instance.
end
end
that is similar to the model classes:
# in the model
has_many :projects
How do I do it?
I am trying to remove all 's in my model with the following method :
def about_us_sans_spaces
self.about_us = replace(self.about_us, " ", " ")
end
Except! it turns out 'replace' isn't a method in rails. How would you remove the s?
Mind you, I have already tried sanitized, simple_format. My view looks like this right now:
= truncate(sanitize(simple_format(organization.about_us_sans_spaces), :tags => ''), 125).titleize
Hey all, I'm running into an error using form_tag in Rails 2.3 and can't seem to wrap my head around it. What may I be doing wrong syntactically?
=form_tag :action => 'form', :name => "admin_form"
#images_actions_bar
=submit_tag "Approve", :class => "button", :name => "approve"
=submit_tag "Update", :class => "button", :name => "update"
I am seeing "syntax error, unexpected kENSURE, expecting $end"