Displaying 20 results from an estimated 8000 matches similar to: "How to download a dynamically generated file"
2008 Dec 16
3
Princely Plugin: get nil.size error
Hi All,
I want to generate pdf with css. I am using princely plugin.
This is code which I written
def pdf
prince = Prince.new()
html_string = render_to_string(:template =>
''/users/paid_invoice.pdf.erb'')
send_data(
prince.pdf_from_string(html_string),
:filename => ''some_document.pdf'',
:type =>
2010 Jun 03
1
need to save generated pdf in public folder
hai
im ruby on rails developer, im integrating princely plugin and prince
software to my rails application
i have generated pdf file successfully using the following code
princely = Princely.new()
html_string = render_to_string(:template => ''test_methods/
visual_test/generate_report.rhtml'', :layout=> false)
send_data(
2006 Nov 17
4
set empty values as null in the database
Le''s say that I have a table called people and the column middle_name is
nullable. If the user enters say blank or empty space then in the database
it is recorded as empty space. I would like in all my models all empty
spaces to be recorded as null.
I guess I can write a plugin which will do so for all the models but I''m
sure something like that should already be existing.I
2006 Jun 16
2
image_select_tag with name and value
What have I missed
I have a .rhtml with the sandard form parameters
<%= image_submit_tag("excel.gif", :alt => "Download List to Excel",
:border => 0, :name => ''render_action'', :value => ''excel'' ) %>
Which genenerates I believe a valid html fragment for a submit button.
<input alt="Download List to Excel"
2006 Aug 09
6
How to change the error message easy way
validates_presence_of :fname
results in the error message
"Fname can''t be blank".
What I want is "First Name can''t be blank".
I could do this
def validate
errors.add_to_base("First Name can''t be blank") if fname.blank?
end
I find this clunky and I have to put everyrhing in the validate method. Is
there an easy to get what I want.
I
2005 Oct 25
3
How to get the source code for login generator
Hi,
I installed login generator using gem. It''s installed and it''s working fine.
I wanted to browse the source code of login generator installed by gem. I
couldn''t find the source code anywhere.
Thanks.
-=- Neeraj
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
2006 Jul 26
2
How to highlight the search term in the search result
In the ''basecamp'' product from 37signals if I search for ''ruby'' the I get a
bunch of results. In the search result page the search term (ruby in this
case) is highlighted.
I was wondering how to accomplish the same.
How to highlight the ''search term'' in the search result? Is there any
already existing utility that I could use?
Thanks.
2006 Apr 27
2
How to override pagination_links method
I intend to override pagination_links method.
I added following lines of code in application_helper.rb
module ActionView
module Helpers
def pagination_links(paginator, options={}, html_options={})
raise("boom!!")
end
end
end
But my code is not executing my code. The view is still using the method
pagination_links from rails.
What''s the correct way to override
2006 Jan 31
2
Relationship navigation issue
class Event < ActiveRecord::Base
belongs_to :venue
belongs_to :category
end
class Venue < ActiveRecord::Base
belongs_to :city
end
class City < ActiveRecord::Base
belongs_to :state
end
I want to retrieve all event records belonging to a state. Coming from
hibernate background I tried something like this:
def self.list_for_a_state(state_id)
find_by_sql(["select e.*
2006 Jul 05
2
How to write get functional test when there is no action by that name
I have following line in route.rb
#event info for an event name
map.connect ''event/:name_url'',:controller => ''home'',:action =>
''event_info''
It causes a URL like http://localhost:3000/event/_jewels_exhibition_ to be
sent to the home controller with action as ''event_info''.
I am trying to test this action. My first
2010 Jul 04
2
Rendering a different format in the implementation of a renderer
Yehuda has a nice article on implementing a custom renderer for PDF at
http://www.engineyard.com/blog/2010/render-options-in-rails-3/
I''ve tried to follow the example and I''m not sure I see how to get it to
work. If I understand things correctly, the format(s) usable in this
render call
respond_with(@resource) do |format|
format.xyz { render :xyz => ... }
end
2006 Jan 14
3
How to render from a different controller
My code is something like this.
class FirstController < ApplicationController
def foo
#some processing
render (:controller => ''second'', :action => ''index'')
end
end
I tried using both render and redirect but it seems it''s not possible to
send the control from within a controller to some other controller. Am I
missing something
2007 Dec 18
2
attachment_fu and S3 -- cannot download file correctly
I don''t know why this isn''t working. If I download a word doc that I
uploaded, all I get is the S3 file path in the document. If I access
the s3 file path directly in my browser, it downloads the file
correctly.
Here is my controller method:
def download
@curriculum = @school.curriculums.find(params[:id])
send_data @curriculum.attachment.public_filename,
:filename
2005 Oct 14
1
Diff between attr_accessible and attr_accessor
I''m going though the paper back edition of agile development with Rails. On
page #128 I encountered following lines of code:
attr_accessor :password
attr_accessible :name,:password
What''s the difference between attr_accessor and attr_accessible?
-=- Neeraj
_______________________________________________
Rails mailing list
2006 Jan 09
6
Rendering dynamic Gruff image (send_data)
Dears,
Got a controller witch do a send_data for displaying a chart.
like :
send_data(g.to_blob, :filename => "any.png", :type => ''image/png'',
:disposition=> ''inline'')
I actually do a
<img src="http://myhost:3000/stats/make_graph" />
Is there any way more clean to do that ? At minima don''t hardcode the
beginning
2008 Feb 19
3
render_to_string in a controller test?
Hi all,
I know that in general, view and controller tests should be isolated,
such that controller specs don''t test views etc. However, I think
I''ve run into a situation that might be an exception.
My controller uses render_to_string to produce a chunk of HTML that it
passes to a model to be processed.
The controller then redirects the user to a different page. The
2007 Apr 19
4
render_to_string in a model ?
I have a batch job that will call script/runner, I would like in this
call to create html formated email and save it to the database. This is
easy enough in a controller with
yournewhost.email = render_to_string :action => "email_newhost_ready",
:layout => false
But render_to_string is only available in controller action pack, is
there a easy way to render_to_string in a Model? Or
2007 Nov 30
5
render_to_string in an after filter
I''m using render_to_string in an after_filter, which renders a partial
that is sent to a web service. Here''s the code:
class MyController < ApplicationController
after_filter :post_to_webservice
def show
# show logic
end
def post_to_webservice
stuff = render_to_string :partial => ''stuff''
webservice_post(stuff)
end
I get a DoubleRenderError in the
2006 May 26
8
calling render_to_string outside of controller
How can I call render_to_string outside of a controller. I''m stuck on
this. I''ve nearly got my plugin finished but I can''t seem to get this
to work. The method is in ActionController::Base but it is protected.
--
Posted via http://www.ruby-forum.com/.
2007 Nov 25
2
Fwd: Render_to_string from a worker
Hi,
I am trying to generate a PDF from within a worker using PDF::Writer. In my
controller I use render_to_string to create the pdf file however from what I
understand render_to_string can only be used from a controller.
Does anybody have any suggestions how I might be able to replicate this
functionality in a worker?
--
thanks,
Felix
-------------- next part --------------
An HTML attachment