To completely get rid of the SQL queries issue, you can use staugaard's wonderful kasket gem (that Zendesk also uses, so, you know, probably okay for production :D)
If anybody else wants to use caching in their decorators / presenters and use HAML, then this is how to do it:
include Haml::Helpers
def haml_cache(key, &block)
self.init_haml_helpers
buffer = haml_buffer.buffer
h.with_output_buffer(buffer) do
h.cache key do
h.concat(yield)
end
end
Does anyone know if / how / links to an API or such that will allow me to pull for instance just one graph into my Rails app, for example for showing number of visits to a user's page on that user's dashboard?
You are both right and wrong. Redis is a memory-only key-value store, but you are free to specify dump intervals in your redis config where it saves its contents to disk. Check the docs for more.
Javier, I am, along with Bootstrap-Sass. See my above comment for an initializer that works, when used alongside the Formtastic-bootstrap gem (sorry, dont know for simple_form)
If you are using bootstrap-sass, and want to get will_paginate working flawlessly, add the following in an initializer (e.g. config/initializers/will_paginate.rb):
if defined?(WillPaginate)
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
protected
def html_container(html)
tag :div, tag(:ul, html), container_attributes
end
def page_number(page)
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
end
def previous_or_next_page(page, text, classname)
tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
end
def gap
tag :li, link(super, '#'), :class => 'disabled'
end
end
end
end
end
If anyone else is using this combination, and need to create a "between" input (e.g. from date to date), it can be done with meta_search's between field (see how to add it in the meta_search docs), and add this input to Formtastic (/app/inputs/between_input.rb)
class BetweenInput < FormtasticBootstrap::Inputs::StringInput
def to_html
input_wrapping do
label_html <<
builder.multiparameter_field(method, {:field_type => options[:field_type]}, {:field_type => options[:field_type]}, input_html_options.except(:id))
end
end
end
(The .except :id is because Formtastic will othwise make both the between field's id's the same, which will mess up e.g. jQuery UI datepicker)
Just to confirm that it is working: I am using the bootstrap-sass gem in a project right now with Bootstrap 2.0 and Formtastic 2.0 It works beautifully :-)
To everyone needing to implement Solr in production mode, I have a couple of hints and warnings:
1) Use the official Apache guide to setting up Tomcat/Solr. It was by far the easiest for me to get working. It is found here: http://wiki.apache.org/solr/SolrTomcat
2) Remember to set the path: in your sunspot.yml. In the case of the example from the guide, this is: path: /solr-example
For others getting Errno::ECONNREFUSED: Connection refused - connect(2) errors when testing Solr-enabled models with Cucumber, put this in your env.rb file:
Sunspot::Rails::Server.new.start
at_exit do
Sunspot::Rails::Server.new.stop
end
This will start up your solr server when your tests start, and shut it down afterwards.
Bitencode, I am SO glad I stopped by the comments section here after debugging for 3 hours :D thank you!
To completely get rid of the SQL queries issue, you can use staugaard's wonderful kasket gem (that Zendesk also uses, so, you know, probably okay for production :D)
https://github.com/staugaard/kasket
If anybody else wants to use caching in their decorators / presenters and use HAML, then this is how to do it:
end
Does anyone know if / how / links to an API or such that will allow me to pull for instance just one graph into my Rails app, for example for showing number of visits to a user's page on that user's dashboard?
There is a little information about doing so here: https://github.com/paulasmuth/fnordmetric/issues/60
I've just now asked for an example / gist
You are both right and wrong. Redis is a memory-only key-value store, but you are free to specify dump intervals in your redis config where it saves its contents to disk. Check the docs for more.
Javier, I am, along with Bootstrap-Sass. See my above comment for an initializer that works, when used alongside the Formtastic-bootstrap gem (sorry, dont know for simple_form)
If you are using bootstrap-sass, and want to get will_paginate working flawlessly, add the following in an initializer (e.g. config/initializers/will_paginate.rb):
If anyone else is using this combination, and need to create a "between" input (e.g. from date to date), it can be done with meta_search's between field (see how to add it in the meta_search docs), and add this input to Formtastic (/app/inputs/between_input.rb)
(The .except :id is because Formtastic will othwise make both the between field's id's the same, which will mess up e.g. jQuery UI datepicker)
Just to confirm that it is working: I am using the bootstrap-sass gem in a project right now with Bootstrap 2.0 and Formtastic 2.0 It works beautifully :-)
To everyone needing to implement Solr in production mode, I have a couple of hints and warnings:
1) Use the official Apache guide to setting up Tomcat/Solr. It was by far the easiest for me to get working. It is found here: http://wiki.apache.org/solr/SolrTomcat
2) Remember to set the path: in your sunspot.yml. In the case of the example from the guide, this is: path: /solr-example
3) If you're going to search for special characters, such as æ ø å (Danish characters), you need to add UTF-8 encoding to your tomcat config file, as described here: http://e-mats.org/2008/04/solving-utf-8-problems-with-solr-and-tomcat/
and here: http://wiki.apache.org/solr/SolrTomcat#URI_Charset_Config
For others getting Errno::ECONNREFUSED: Connection refused - connect(2) errors when testing Solr-enabled models with Cucumber, put this in your env.rb file:
Sunspot::Rails::Server.new.start
at_exit do
Sunspot::Rails::Server.new.stop
end
This will start up your solr server when your tests start, and shut it down afterwards.