rubyonrailsin

A Ruby and Rails talk

Monday, March 29, 2010


[Rails] saving data from database to text/yaml file

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hello all...

I am new to rails.
I have a rails app in which i want data from my database table into a
text file.

I have a notices table that has three fields - title, body and user. I
want this data to be stored in a text or yaml file.

Here is the code of what I am trying to do... But I am not able to get
it done.

def save
@notice = Notice.find(params[:id])
f = File.new("#{RAILS_ROOT}/public/notice.txt","w")
debugger
f.write @notice
f.close
end


Please help me.

--
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.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive