Hi,
I am like 50% through with this topic - but my assets are killing
me :)
Shared a pdf of how I understand Rails handles requests:
https://docs.google.com/open?id=0B7DR8cTEbs3ta2JOR0l2RlVRZHlSdUVTTTFHaFFwdw
Andrew White (amongst others) lead me on my way to adding the
ViewTemplate Model and accompanying Resolver class.
So, now I can serve templates and partials from the database - but
with client-side rendering ''on the rise'' (lately LinkedIn
promoted
Dust.js templating) - I would like my Rails to serve compiled*) view
assets (templates) persisted not to the file system but to the
database (because my Rails app should be able to handle a large number
of view assets to a large number of customers like:
customer #1
posts/index: this is {{ customer.name }}''s posts
customer #2
posts/index: {{ something }}
I am perfectly aware that I may be displaying my utter ignorance on
the subject and that this is neither "how it''s done" nor very
well
described let alone possible at all - heck, it may even be included in
the current master! In any case I do apologize and stand willingly
corrected if someone will please point me to the correct way it''s done
<:)
Elsewise - is this a feature which the rails-core will consider - or
should I hurriedly follow the advice to Alex Foley given by Victor
Maitland? (http://www.imdb.com/title/tt0086960/quotes?qt=qt0415491)
Cheers,
Walther
*) serving the view uncompiled is possibly if I will accept the
penalty of having the client do a dust.compile( source )
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.
Walther Diechmann
2012-Mar-01 09:30 UTC
Re: Serving database ba(c)ked templates and assets
One very in-elegant way of working around this obstacle would be to add
match ''assets/*:id'', to: ''assets#serve''
to my config/routes.rb, add a helper to list all required assets in the
<head>
def asset_to_head(asset)
# write <script, <style, <link, whatever - and remember to set src=
asset.hashed_path
# eventually leading to something like
src=''lib/some_name-234523419575.format''
end
and then implement the required logic to handling assets within the
assets_controller.rb
def serve
asset=ViewTemplate.assets.find_by_path(params[:id] + ''.'' +
params[:format])
send_as_file(asset) ) if asset and return
send_file params[:id] + ''.'' + params[:format]
end
def send_as_file(asset)
# build temp-file
# send tempfile
end
- but I''d wager there to be a much smarter way! (For one I''d
suspect a rack
middleware thing could come in pretty handy - but I''m not up to speed
on
middlewares)
Cheers,
Walther
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/3kyViXa_u8cJ.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.