Thursday, March 18, 2010

[Rails] Re: render a Google Chart to a file

Use following method to get image in file from any url


Net::HTTP.start("#{DOMAIN_URL}") { |http|
resp = http.get(PARAMS)
open( "#{OUTPUT_DIR}/#{file_name}.png", 'wb' ) { |file|
file.write(resp.body)
}
}

Where DOMAIN_URL: http://chart.apis.google.com
PARAMS:
/chart?cht=bvg&chbh=a&chd=s:vttusty&chs=500x300&chxt=x,y&chxl=0:|Sun|Mon|Tue|Wed|Thu|Fri|Sat|1:|0|2|4|6|8|10|12


Thanks
Brijesh Shah
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] migration

Hi all,

I have migrated with some tables in my application. After some days i
need to add few more tables to database. The initial tables in database
have some data. when i try to migrate the database for second time with
rake db:migrate it is saying the alredy table exist <table name> and
rake is aborted. i dont want to loose the old data and i want to add new
tables to alredy exiested database

how to do this. Please help me.


Regards,
Rajkumar.
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Will paginate display

Hi friends i am using will_paginate plugin for pagination
Im having more records in my database im listing 10 records per page
know my pagination link was look like this
<< Previous    1 2 3 4 5 6 7 8 9 266    Next >>

But i would  like to display the pagination links look like this

<< Previous    1 2 3 4 5 6 7 8 9 10    Next >>

any idea how to implement this please help me to implement this

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: RJS error: TypeError: element is null

> I believe this is expecting to find a div with id chat_area to
> replace. I do not see this div in the code below, though I may be
> just not be seeing it.
>
> Colin
Following div is present on my index.rhtml

<div id="chat_area">
<%= render :partial=>'chat_area' %>
</div>


I don't know what is the problem with this div or partial's content
while using same technique i am updating my other div's

Regards,

Salil Gaikwad
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Rails, 1.9 & Encoding - does it work?

Hey all,

I've been looking into moving our Rails app to 1.9 and am having lots of
trouble with string encodings, especially when it comes to file uploads.

We allow users to upload text files, which may, or may not, have
accented characters in them. If there are accented characters, we insist
that the file is UTF-8, but if there are no accented characters we don't
care what encoding the file is.

It seems that w/ Rails 2.3.5 ALL files upload as ASCII-8BIT, regardless
of OS $LANG setting, or actual file encoding.
params[:file].external_encoding also appears to be ASCII-8BIT as well,
so I can't use content.encode("utf-8", xxx) because I've no idea what
the file is *supposed* to be encoded as.

Since I'm on OSX and $LANG == en_AU.UTF-8, shouldn't all files default
to UTF-8 unless explicitly told otherwise?

Has anyone got 2.3.5 working well w/ 1.9 when accented characters are
involved?

Any tips?

thanks,
donncha
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] Re: Records created while tests are running are not being saved.

Just for records. Line #47 -
http://code.google.com/p/kopal/source/browse/test/network/connect_controller_test.rb?r=876e7c80c420e5faca9492bd50ed1dd943cb90ac

On Mar 18, 3:08 pm, Vikrant Chaudhary <nas...@gmail.com> wrote:
> In following code -
>
> require "test_helper"
> Class SomeControllerTest < ActionController::TestCase
>
>   def test_something
>     record = SomeModel.create :name => 'test'
>     record.save!
>     gets
>   end
>
> end
>
> Above record is not being saved in the database. I can confirm this by
> pausing execution by calling gets() and doing a "SELECT * FROM
> some_models" right into the test database which returns no rows.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

[Rails] getting data from a through table

im using has_many through and the through table has some data i want
but i cant seem to access it using straight rails

<code>
class AttributeObjects < ActiveRecord::Base
belongs_to :attributes
belongs_to :objects
end

class Attributes < ActiveRecord::Base
has_many :attribute_objects
has_many :objects, :through => :attribute_objects
end

class Objects < ActiveRecord::Base
has_many :attribute_objects
has_many :attributes, :through => :attribute_objects
end

</code>

now imagine that attribute_objects also contains a rating
so when i say, object.attributes, id like to get the rating too
that doesnt seem to be possible with the has_many relationship
if i could force the join on the object attributes to bring the
attribute_objects fields also...maybe

i think i have to write custom sql for this

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.