merb-devel at rubyforge.org
2006-Dec-07 17:19 UTC
[Merb-devel] What does js partial(...) do?
In the example application named "sample_app", comment.jerb contains the following line: $(''comments'').update(<%=js partial(:comments) %>); What does the ''js'' method do to/with, if anything at all, ''partial(:comments)''? Merb is quite fun to use and I''m starting to get a feel for it and ruby. I''m surprised at how quickly it enables me to create my little application. Are there plans to make Merb more visible as some other mini-framework projects have done (thinking of Camping as an example)? Ed
merb-devel at rubyforge.org
2006-Dec-07 17:48 UTC
[Merb-devel] What does js partial(...) do?
This file in the track holds all a few Java Script goodies: http://merb.devjavu.com/projects/merb/browser/lib/merb/mixins/javascript_mixin.rb You should check that file out! But in there it says: "calls .to_json on data." Hence it converts converts the output of partial into JSon from what "I" understand... Hope that helps! Also, what do you mean by, "make Merb more visible" ? Chino P.S. Come hang out in merb at freenode ! merb-devel at rubyforge.org wrote:> In the example application named "sample_app", comment.jerb contains > the following line: > > $(''comments'').update(<%=js partial(:comments) %>); > > What does the ''js'' method do to/with, if anything at all, ''partial(:comments)''? > > Merb is quite fun to use and I''m starting to get a feel for it and > ruby. I''m surprised at how quickly it enables me to create my little > application. Are there plans to make Merb more visible as some other > mini-framework projects have done (thinking of Camping as an example)? > > Ed > _______________________________________________ > Merb-devel mailing list > Merb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/merb-devel >
merb-devel at rubyforge.org
2006-Dec-07 18:46 UTC
[Merb-devel] What does js partial(...) do?
On Dec 7, 2006, at 9:19 AM, merb-devel at rubyforge.org wrote:> In the example application named "sample_app", comment.jerb contains > the following line: > > $(''comments'').update(<%=js partial(:comments) %>); > > What does the ''js'' method do to/with, if anything at all, ''partial > (:comments)''? > > Merb is quite fun to use and I''m starting to get a feel for it and > ruby. I''m surprised at how quickly it enables me to create my little > application. Are there plans to make Merb more visible as some other > mini-framework projects have done (thinking of Camping as an example)? > > EdHey Ed- partial(:comments) just renders the _comments.herb partial template. The js method calls .to_json on that partial content to properly escape the text for the browser so it doesn''t choke on unescaped html. .jerb templates set the content type to javascript so that the browser executes it. Similar to rjs except .jerb you just write your javascript yourself and then use erb tags to make parts of the js dynamic. Merb is fun, I''m glad you like it. I do plan on making a merb wiki or site soon. I am just super busy so I am not sure when I will get the time. Also Ed I think you were the one asking about ActiveRecord sessions and reading the rails sessions in merb. Last night I commited this functionality. I made an ActiveRecord sessions store that can use the same sessions table as your rails app. You can also pass the session_id in the query styring when you redirect to merb from rails. Merb will pick up the sessions_id from the query string and find the proper sessions from the rails sessions table. You can modify and save the sessions and rails will pick up those changes ion its side as well. To use this you just need to make sure you have a sessions table (look at the sample app for a migration to create one) and then you must set a config option in your dist/conf/merb.yml --- :host: 0.0.0.0 :port: "4000" :allow_reloading: true :sql_session: true ^^ the sql_session is set to true and then merb will take care of setting up the AR sessions. Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
merb-devel at rubyforge.org
2006-Dec-07 19:08 UTC
[Merb-devel] What does js partial(...) do?
On 12/7/06, merb-devel at rubyforge.org <merb-devel at rubyforge.org> wrote: ------8<------8<------8<------8<------> The js method calls .to_json on that partial content to properly > escape the text for the browser so it doesn''t choke on unescaped > html. .jerb templates set the content type to javascript so that the > browser executes it. Similar to rjs except .jerb you just write your > javascript yourself and then use erb tags to make parts of the js > dynamic.Ahh, very helpful info. ------8<------8<------8<------8<------> sessions and reading the rails sessions in merb. Last night I > commited this functionality. I made an ActiveRecord sessions store > that can use the same sessions table as your rails app. You can also > pass the session_id in the query styring when you redirect to merb > from rails. Merb will pick up the sessions_id from the query string > and find the proper sessions from the rails sessions table. You can > modify and save the sessions and rails will pick up those changes ion > its side as well.------8<------8<------8<------8<------ That''s super news Ezra! Thanks for implementing that option - it really helps what I''m doing with Merb. Thanks again, Ed