How to use Carrierwave with the Volt framework? - file-upload

It is pretty straightforward to use Carrierwave with Rails but not so much with Volt. I would like to know if it is possible to use CW with Volt, and what is the best way to do it.

It's most likely possible. Volt is a rack app, and you can add other middleware (see the volt docs for help with that) Sorry I can't be of more help, but my time is limited right now. Anyone else want to give it a try?

Related

Advanced Ajax with RoR and jQuery UI

I don't have much web development practical experience although I had studied a lot on the web (Treehouse, CodeSchool, other tutorials and articles).
I have found some explanations on how to use Ajax with RoR and jQuery. But I'm having difficulties to understand how to solve my problem as the explanations often use jquery-ujs that I suppose I can't use in my case.
My problem is difficult to explain here but is similar to implementing this shopping cart on RoR, including more parameters like price
The jQuery UI is working for me in my RoR application. What is missing is the AJAX part and how to make it work with RoR
I have found some questions here on StackOverflow that is about this topic but it didn't helped much as they are probably for more advanced users.
So, I believe that the best help would be a tutorial or book or some other reference that is more similar to my problem. However any advice or other kind of directions may help
After struggling a lot, finally I solved my problem.
I will post here the resources and some tricks that helped me. I hope it can help others. StackOverflow didn't let me post all the links. For this reason, I just gave some hints that may help to find some resources.
About the jQuery Ajax concepts, I recommend Code School jquery course "The Return Flight".
The second thing that I think helps is learn to debug. Firebug helped me a log to debug the client side/javascript/Ajax. This link may help on that:
http://www.zyxware.com/articles/2642/debugging-tips-how-to-debug-ajax-requests-using-mozilla-firefox-and-firebug
Since the problem may be to debug RoR. Look for a RailCast on the subject.
One of the things that I took some time is if it would be better to use $.ajax(), $.post(), $.get() or $.getJSON(). The link below may explain better but to sum it up, $.ajax() is the more generic one and the other are simpler ones and that call $.ajax() with specific parameters.
Difference between $.post and $.ajax?
It is important to understand how RoR routing works to call the right url with the right $.ajax() type. "rake routes" may help.
This link may also help to use the right $.ajax() type.
http://old.thoughtsincomputation.com/posts/understanding-rest-in-rails-3
Finally, to send the right format from the javascript to RoR controller, this link may help:
How to send and store data to rails through jquery/ajax as a JSON object?

Has anybody used AspectMap?

I have just stumbled accross the following AOP framework built on top of StructureMap and was wondering if anybody has any experience using it.
Any good, any issues?
http://www.chrissurfleet.co.uk/post/2012/06/27/AspectMap-Part-5-Aspect-Nesting-and-Prioritising.aspx
Or can you suggest any alternatives?
I use it, and like it, but then I built it! Its nice and easy to get started with, but isn't as full featured as some of the alternatives.
The nice thing is though that the code you write is generally reusable - so if you decide you want to use something else it will be easy to swap the aop provider out. Or you can easily start with something else and move onto AspectMap ;)
If you've got any questions feel free to mail me via the blog, or just ask on here

Span Queries in SOLR

How does one issue span queries in SOLR (Span, SpanNear, etc)? I've
done a bit of research and I can't tell of a straightforward way to do it.
It would seem that I need to implement a QueryParserPlugin to accomplish
what I want to do. Is this the correct path? Surely this has been done before. Does
anybody have links to examples? I had trouble finding anything.
Span queries aren't currently supported (JIRA issue here).
Judging by this mail thread, it seems that you're on the correct path by implementing a QueryParserPlugin.
If you do implement this, consider submitting a patch!

Simple_form or formtastic: which one to choose?

I've been spending some hours searching for useful Rails gems but I still hesitate between simple_form and formtastic.
I know they look really similar but I really don't know what I have to choose for my new project. I'd want it to be customizable enough concerning HTML / CSS but still very complete (I have to use bitmask checkboxes).
What can you advise me ?
Thank you in advance.
Both are powerful enough, but if you really want customizable HTML/CSS, simple_form is a bit easier to use. formtastic already groups and adds a bit of style to your form elements, and it's not always easy to customize.

Expose function in ruby on rails

I am looking at a rails app and at the top of every controller there is a block of code that looks something like this
expose(:var) {Model.find params[:var_id]}
I understand what is inside the block just fine but...
I cannot find any documentation on what the expose function does where it comes from or anything I have tried searching the project and using the searchable rails docs.
I would love to know what it does, can someone please tell me or point me to the docs.
This is probably referencing the decent_exposure gem. You can learn more about it here: http://railscasts.com/episodes/259-decent-exposure
Source: https://github.com/voxdolo/decent_exposure
It's a method from the Decent Exposure gem. You can check out a screencast that Ryan Bates did on it over at Railscasts. It's a really great gem. I use it in my application. It cuts down on a lot of the redundancy in the controller layer.
expose is not a part of Rails, it comes from the decent_exposure gem.
It is not an answer to the question. I just want to make the Rails world a bit better and I hope that somebody will read this.
Please think twice before using expose. You should only use it if you 100% sure you are using it the right way and it really makes the code better. Read the documentation properly!
One of projects I worked on became unmaintainable because of tons of expose in controllers which replaced not only all #instance_variables passed to views, but also a lot of business logic and the most helper methods.
When you use expose it is not clear in which controller actions and in which views it is used. Unexperienced developers combine data and logic for multiple actions and multiple views in the same expose block.
That's a nightmare.
Believe me, expose really destroys projects if not used properly.