From what I can tell, creating a theme in Spree is very similar to customizing the application like I showed here. The only difference is that you're working on an engine instead of the application. Check out the blue theme and the Rails Dog Radio theme for good examples.
I really like this screencast but am having problems implementing this because I use haml, besides telling me to switch to erb, is there any advice you can provide about implementation of this with haml. I have googled and there seems to be some suggestions that there are problems with haml, specifically with respect to this issue here https://github.com/nex3/haml/issues/450.
I hope to see the in depth how to create an theme for Spree. I guess it would result both, useful for the a particular developing task, but it could really help the spree community to boost on creating various themes for the engine.
Same here. The error happens when i include ActionView::TestCase::Behavior. I'm using rails 3.1.1. The setup action is called inside the Behavior module itself. So, how do i get access to views in RSpec?
...and looking at the 'cast again, I'm further conflicted. I'd be inclined to put something like avatar_name in its own partial (or even helper), but neither is satisfactory from an OO point of view, as I mentioned already. At the same time, I wouldn't want to put that much HTML generation in the model, I think, and Cells, while very promising, seems to be trying to solve a different problem (though I could well be wrong). Hmm.
How is putting something in the decorator any better than putting it right in the model class? The Presenter pattern is designed to abstract display logic from one (or several) model objects whose data model isn't much like the view. That's not what's going on here, as far as I can tell. Looks rather like you're reinventing helpers.
Now, there may be some call for doing that: as you point out, helpers are among the least satisfactory parts of Rails from an OO design perspective. But I tend to think this is not the right solution to that problem.
OTOH, I usually trust you, so I'm interested in hearing more about your rationale here.
I'll try to be more specific. I need to execute some JS snippet on he client side (actually it's executing google analytics code), but I want to run it from a controller on my app (the controller action redirects automatically without rendering html, don't ask why.. :-)
So, I'm not sure whether ExecJS + therubyracer can do that
For some reason :child_index isn't working for me in rails 3.0.10. My code is also modified to allow reordering. I am also using formtastic 1.2.4 with haml, and have tried switching the semantic_fields_for to fields_for and have also tried with or without the new_object as an array as a previous commenter noted. Here is the code:
When there are naming conflicts, the first path that appears in the config.assets.paths array is the file that is chosen. This can be avoided by using the asset_path() helper and specifying the directory.
I didn't quite get this comment though. Isn't it what session hijacking is about?
I may be misunderstanding your comment, so please correct me if my basic understanding about the security design is wrong.
If some malicious people gets user_id, he can create a request with session[:user_id] to by-pass login. So, it is always better to use SSL to avoid session cookies to be sniffed out.
To enhance the security further in highly sensitive system, it would be better to use a session id that changes its value according to the login time (unlike user_id)
Would have loved to see this working across different lists (moving items from one to the other). I already have something working for this, although I don't think it is very efficient.
Usually, your client side will be a web browser that can execute JS code without any third-party library, so ExecJS is not needed in this case (and wouldn't work, since ExecJS needs a Ruby interpreter, that is not available in any standard web browser).
Hi all, i have a problem i followed the tutorial and when I try to sign up through Facebook i get this error:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException"
}
}
Thanks for the kind words.. And yeah, that's the basic idea, but it becomes pretty heavy on the server side and I've intentionally kept that to a minimum (see complaint about formtastic and paperclip above).
You can just adjust the configuration to point to a different route/path when loading the history panel, so it's as simple as writing a view that you want to see. =)
So, yeah.. it does have these dependencies, but I will likely drop formtastic -- as it was only used as a convenience for the example snippet options form. I've been meaning to for a while now.
I am not sure I am clear on how you would update the view w/ the progress of a job, or the results of a job? Having to refresh is obviously not an ideal implementation, bu it seems like you did that in this screencast as well as the BeadStalkd + Stalker one... Am I missing something ? Do you have any suggestions on how I could update the view automagically when the job is complete?
I too had an issue with this, you have to do some magic converting the param to a correct JSON format, but the easier solution (at least for Rails) is to use the form method to send the data, instead of the default json method.
Simple, add a conditional statement to the line where you include mercury.js. Without this file Mercury never loads, so something like this would solve your issue:
Ruby
<%= javascript_include_tag('mercury') if current_user %>
Actually you are right, mercury-rails does have a few conventions (using Formtastic and Paperclip), but Mercury (the editor) doesn't use any of these dependencies, it's only the Rails backend that uses it. But you are free to use any backend you want. The forms for the modals can be customized so you can do without both Formtastic and Simpleform if you want, and I myself use Carrierwave with Mercury without ever lookign at Paperclip.
So I don't see how it is annoying that Mercury includes a few simple examples/conventions for you to get started without almost any coding on the server side.
I have only just found my love for testing. test unit suits me much better, I tried using rspec for years but we never gelled. Maybe try switching test suites?
Mercury-rails has a dependencies on Formtastic and Paperclip, which I find personally annoying. I tend to use Simpleform and Carrierwave myself, so I'm working on a fork that will remove these dependencies and employ a concept of providers for image-handling. Not sure what to do about Formtastic. It's almost syntactically compatible with Simpleform, but it's use is quite limited. I think a way to delegate options form building to your application would be better, then you'd be free to handle it however you like. All in all, Mercury is awesome, and I'm using it myself. Kudos to Jeremy for sharing it.
Hmmm, some good points made in these comments. And I have to say I'm leaning towards Sergey Kuleshov's comment. This is a very cool screencast, but I'm not sure I'd go this far in a production project.
I like that you're showing us Coffeescript usage too Ryan, it's lowering the barrier for me, but I've got to say, I still prefer straight Javascript. I still find Coffeescript very hard to read. Ultimately, I think I'd love to be able to write my Javascript in Ruby.
The similarity of Ruby's new hash syntax is bringing the two closer, and this is something I adopted only this week. Yeah, I know... slow on the uptake.
From what I can tell, creating a theme in Spree is very similar to customizing the application like I showed here. The only difference is that you're working on an engine instead of the application. Check out the blue theme and the Rails Dog Radio theme for good examples.
It is a bit slow in development mode, see the performance section in the readme here for how to improve it. Also you may want to try Active Reload.
+1 for a follow up cast.
Did you get this to work in the end? I'm having the exact same problem...
I really like this screencast but am having problems implementing this because I use haml, besides telling me to switch to erb, is there any advice you can provide about implementation of this with haml. I have googled and there seems to be some suggestions that there are problems with haml, specifically with respect to this issue here https://github.com/nex3/haml/issues/450.
@Stephane - There's some tips on the spree blog for rails 3.1 performance:
http://spreecommerce.com/blog/2011/08/18/pre-compiling-assets-on-edge/
I agree this is so interesting and helpful, it would be great to see another one, thank you!
I hope to see the in depth how to create an theme for Spree. I guess it would result both, useful for the a particular developing task, but it could really help the spree community to boost on creating various themes for the engine.
However, it was excellent as always.
Thanks Ryan.
i cant get sorting to work for text field (not
string
one)i have an exception:
Sunspot::UnrecognizedFieldError (No field configured for Article with name 'name')
if i reindex with
string :name
- it become sortable but i loosing possibility to nGram search on that fielddid anyone have same issue and got solution to it?
There is a bug report with rails 3.1 spree 0.70.1, nokogiri 1.5.0 and ruby-1.9.3-p0 https://github.com/tenderlove/nokogiri/issues/561
And I have this bug ;-)
But for the slowness, you can use RailsDevTweaks
Great episode, I would like to see more episodes about rails internals.
Thank you.
But did you have some problems with rails 3.1 ? the system seems to be very slow in development mode.
Same here. The error happens when i include ActionView::TestCase::Behavior. I'm using rails 3.1.1. The setup action is called inside the Behavior module itself. So, how do i get access to views in RSpec?
Great idea! Thanks a lot Ryan!!! Before I put header global variable in a controller (((
For layout:
and view:
It doesn't work on rails 3.1.1
Solve:
...and looking at the 'cast again, I'm further conflicted. I'd be inclined to put something like
avatar_name
in its own partial (or even helper), but neither is satisfactory from an OO point of view, as I mentioned already. At the same time, I wouldn't want to put that much HTML generation in the model, I think, and Cells, while very promising, seems to be trying to solve a different problem (though I could well be wrong). Hmm.Doesn't that logic go in the model?
How is putting something in the decorator any better than putting it right in the model class? The Presenter pattern is designed to abstract display logic from one (or several) model objects whose data model isn't much like the view. That's not what's going on here, as far as I can tell. Looks rather like you're reinventing helpers.
Now, there may be some call for doing that: as you point out, helpers are among the least satisfactory parts of Rails from an OO design perspective. But I tend to think this is not the right solution to that problem.
OTOH, I usually trust you, so I'm interested in hearing more about your rationale here.
Figured it out, I was passing f instead of builder...
After editing all files and run
rails s
There will be an error on Ubuntu:
autodetect': Could not find a JavaScript runtime.
After i installed node.js
apt-get install nodejs
it works.Greetings
10x Matthiew,
I'll try to be more specific. I need to execute some JS snippet on he client side (actually it's executing google analytics code), but I want to run it from a controller on my app (the controller action redirects automatically without rendering html, don't ask why.. :-)
So, I'm not sure whether ExecJS + therubyracer can do that
Thanks.
I seem to be getting a "sort_faqs_url" not found error when trying to access my controller sort action. Everything matches the above code perfectly
For some reason :child_index isn't working for me in rails 3.0.10. My code is also modified to allow reordering. I am also using formtastic 1.2.4 with haml, and have tried switching the semantic_fields_for to fields_for and have also tried with or without the new_object as an array as a previous commenter noted. Here is the code:
When there are naming conflicts, the first path that appears in the
config.assets.paths
array is the file that is chosen. This can be avoided by using theasset_path()
helper and specifying the directory.+1 for follow up episode on PayPal integration!
Great screen cast Ryan, quality is always!
My bad. I didn't know that Rails3 session cookies are tamper proof... Wow, that makes my life really easy!
Hello Ryan. Thank you for great tutorials! :)
I didn't quite get this comment though. Isn't it what session hijacking is about?
I may be misunderstanding your comment, so please correct me if my basic understanding about the security design is wrong.
If some malicious people gets user_id, he can create a request with session[:user_id] to by-pass login. So, it is always better to use SSL to avoid session cookies to be sniffed out.
To enhance the security further in highly sensitive system, it would be better to use a session id that changes its value according to the login time (unlike user_id)
Would have loved to see this working across different lists (moving items from one to the other). I already have something working for this, although I don't think it is very efficient.
Usually, your client side will be a web browser that can execute JS code without any third-party library, so ExecJS is not needed in this case (and wouldn't work, since ExecJS needs a Ruby interpreter, that is not available in any standard web browser).
Hi, I've ran into an interesting problem which I can't seem to find a solution for. Help is really appreciated.
http://stackoverflow.com/questions/8116314/rails-3-1-paperclip-error-with-custom-processors-and-cropping
Hi,
Probably a newbie question, but I want to be sure...Can I use ExecJS to execute JS code on the client side?
Thanks!
You mention in your video that Airbrake is a paid service, but there is actually a free version as well: https://airbrakeapp.com/account/new/Free
Hi all, i have a problem i followed the tutorial and when I try to sign up through Facebook i get this error:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException"
}
}
I agree. You are doing a great job Ryan!
thanks a bunch, can't wait for vagrant + chef screencast
Thanks for the kind words.. And yeah, that's the basic idea, but it becomes pretty heavy on the server side and I've intentionally kept that to a minimum (see complaint about formtastic and paperclip above).
You can just adjust the configuration to point to a different route/path when loading the history panel, so it's as simple as writing a view that you want to see. =)
So, yeah.. it does have these dependencies, but I will likely drop formtastic -- as it was only used as a convenience for the example snippet options form. I've been meaning to for a while now.
I'm actively maintaining the project, and I'm interested in what you mean here.
It may be easier and not get lost if you submit ideas on the github project https://github.com/jejacks0n/mercury -- with some more details.
Thanks for advice...
Change should be in app/layouts/mercury.html.erb
saveStyle: null, // 'form', or 'json' (default json)
Changing null to 'form' did solve my problem.
Just to tell because I have been looking in mercury.js for quite a long time :-).
I am not sure I am clear on how you would update the view w/ the progress of a job, or the results of a job? Having to refresh is obviously not an ideal implementation, bu it seems like you did that in this screencast as well as the BeadStalkd + Stalker one... Am I missing something ? Do you have any suggestions on how I could update the view automagically when the job is complete?
Thanks!
-John
Maybe gem 'turn', :require => false -- it should pretty printe test output
I too had an issue with this, you have to do some magic converting the param to a correct JSON format, but the easier solution (at least for Rails) is to use the
form
method to send the data, instead of the defaultjson
method.Simple, add a conditional statement to the line where you include mercury.js. Without this file Mercury never loads, so something like this would solve your issue:
<%= javascript_include_tag('mercury') if current_user %>
Actually you are right, mercury-rails does have a few conventions (using Formtastic and Paperclip), but Mercury (the editor) doesn't use any of these dependencies, it's only the Rails backend that uses it. But you are free to use any backend you want. The forms for the modals can be customized so you can do without both Formtastic and Simpleform if you want, and I myself use Carrierwave with Mercury without ever lookign at Paperclip.
So I don't see how it is annoying that Mercury includes a few simple examples/conventions for you to get started without almost any coding on the server side.
Thank you for your casts, always appreciated!
Any advice about implementing it with a category description and category photo? Any comment is welcome!
Hey everyone,
I've implemented a way to change the password (not reset the password) see here.
However I have trouble hooking up rspec tests for this bit of code... If anyone can help me out...
Here is how:
I have only just found my love for testing. test unit suits me much better, I tried using rspec for years but we never gelled. Maybe try switching test suites?
From now , i'll be the regular visitor of your web. Thanks , great info.
http://www.nsdlpan.co.in
Mercury-rails has a dependencies on Formtastic and Paperclip, which I find personally annoying. I tend to use Simpleform and Carrierwave myself, so I'm working on a fork that will remove these dependencies and employ a concept of providers for image-handling. Not sure what to do about Formtastic. It's almost syntactically compatible with Simpleform, but it's use is quite limited. I think a way to delegate options form building to your application would be better, then you'd be free to handle it however you like. All in all, Mercury is awesome, and I'm using it myself. Kudos to Jeremy for sharing it.
Hmmm, some good points made in these comments. And I have to say I'm leaning towards Sergey Kuleshov's comment. This is a very cool screencast, but I'm not sure I'd go this far in a production project.
I like that you're showing us Coffeescript usage too Ryan, it's lowering the barrier for me, but I've got to say, I still prefer straight Javascript. I still find Coffeescript very hard to read. Ultimately, I think I'd love to be able to write my Javascript in Ruby.
The similarity of Ruby's new hash syntax is bringing the two closer, and this is something I adopted only this week. Yeah, I know... slow on the uptake.