Ruby on Rails Wednesday, June 1, 2011

SHORT UPDATE:

Sorry! Stupid idea! I can of course just move my method into the same
controller, so I don't have to leave it.

I have the following in my controller:

def checkall
->check all entries for updates<-

create_report -> This should just run my method below
asynchronously
end


def create_report
->this creates my report<-
end
handle_asynchronously :create_report, :priority => 3


On Jun 1, 9:31 am, Sebastian <sebastian.go...@googlemail.com> wrote:
> OK...I still have a problem:
>
> The render_to_string method is only available in controllers and not
> in models and views!!!
>
> My approach was to check with several delayed_job my database entries
> for changes (compare with external webservice!) and then run a
> delayed_job for create the report with lower priority afterwards.
>
> That is not working because I can't use render_to_string in a model
> for the delayed_job.
>
> Has anyone an idea how to solve this?
>
> Or is it possible to delay a method from another controller?
>
> I am so close! If I just call the method on a view the whole page is
> stored as I want. I only need to do this in a delayed_job...!
>
> @Colin Law: I had a look into caching, but I didn't understand the
> whole thing, so I think for me it would be easier if my first approach
> would work.
>
> Sebastian
>
> On May 26, 11:51 am, Sebastian <sebastian.go...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > render_to_string worked perfectly!
>
> > I just have to this in the controller and not in the view.
>
> > Controller:
>
> > @reportstring = render_to_string(:partial => "shared/
> > compare", :collection => @changedfamilies)
>
> > Then I can save the @reportstring in my database and call the whole
> > view wherever I need it!
>
> > Thank you!
>
> > On May 26, 10:17 am, Colin Law <clan...@googlemail.com> wrote:
>
> > > On 26 May 2011 08:51, Sebastian <sebastian.go...@googlemail.com> wrote:
>
> > > > Thank you all for your answers.
> > > > ...
> > > > @Colin Law: Cache is only temporarily. I need to save the report
> > > > permanently, so cache is no option.
>
> > > A page cache can be as permanent as you like.  It is up to you when
> > > you expire it.  If you never expire it then it will be permanent.  By
> > > doing it yourself you are just re-inventing the wheel.  The work has
> > > already been done for you by Rails developers.
>
> > > Colin

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

Ruby on Rails

OK...I still have a problem:

The render_to_string method is only available in controllers and not
in models and views!!!

My approach was to check with several delayed_job my database entries
for changes (compare with external webservice!) and then run a
delayed_job for create the report with lower priority afterwards.

That is not working because I can't use render_to_string in a model
for the delayed_job.

Has anyone an idea how to solve this?

Or is it possible to delay a method from another controller?

I am so close! If I just call the method on a view the whole page is
stored as I want. I only need to do this in a delayed_job...!

@Colin Law: I had a look into caching, but I didn't understand the
whole thing, so I think for me it would be easier if my first approach
would work.

Sebastian

On May 26, 11:51 am, Sebastian <sebastian.go...@googlemail.com> wrote:
> render_to_string worked perfectly!
>
> I just have to this in the controller and not in the view.
>
> Controller:
>
> @reportstring = render_to_string(:partial => "shared/
> compare", :collection => @changedfamilies)
>
> Then I can save the @reportstring in my database and call the whole
> view wherever I need it!
>
> Thank you!
>
> On May 26, 10:17 am, Colin Law <clan...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > On 26 May 2011 08:51, Sebastian <sebastian.go...@googlemail.com> wrote:
>
> > > Thank you all for your answers.
> > > ...
> > > @Colin Law: Cache is only temporarily. I need to save the report
> > > permanently, so cache is no option.
>
> > A page cache can be as permanent as you like.  It is up to you when
> > you expire it.  If you never expire it then it will be permanent.  By
> > doing it yourself you are just re-inventing the wheel.  The work has
> > already been done for you by Rails developers.
>
> > Colin

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

Ruby on Rails

I did the following which seems to fix the problem, note the last two
set_style calls take a string rather than a hash:

page[k].set_style({:'font-size' => font_sz, :color => col,
:position => 'absolute', :left => (40
+ (horz)), :top => ((tidx * 100) + 70)
#:'z-index' => 20
})
page[k].set_style 'z-index: 20'
page[k].set_style 'font-size: ' + font_sz.to_s

================================================

I found this on the web:

http://groups.google.com/group/prototype-core/msg/48ce0bd3949ff222

where it seems to say:

> Note that for performance reasons, we've deprecated the use of *
> uncamelized* style property names when setting styles using a hash. So If
> you have code that looks like this:

> $("header").setStyle({ "font-size": "12px" });

> You need to replace it with either of the following:

> $("header").setStyle({ fontSize: "12px" });
> $("header").setStyle("font-size: 12px");

..
> Both params "background-color" and "z-index" won't be set anymore
> using 1.6.0.rc0.
> The exact same code does it well by using 1.5.1.1.


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