if you want to get down into the nitty gritty and really focus on the formatting - perhaps take a look at Latex for rails, it was exactly what I was looking for.
After I setting enviorment from Development to Production, the jCrop seems not working correctly. It maybe the problem caused by precompiling and compressing. Any suggestions? Thx!
Is there a way to use the same Facebook app for both production and development?
I mean, in FB app settings you can provide only one Site URL, which for development is usually http://localhost:3000/ and for production your actual URL where the application is hosted.
Of course you could create a separate "development facebook app" with a different APP ID and SECRET and localhost:3000 as login callback url, but it would be nice, if OmniAuth Facebook and the same fb app could handle both development and production.
Morris.js looks super simple to setup and use.
My line charts required logarithmic Y-axis. So I had to settle on the Google Visualization API with the Visualr Gem. However, over time, I found it somewhat rigid. Therefore, I had to go to HighCharts which can do just about everything that I need to do. As Ryan points out, it is a commercial product though.
you have to combine Rails and LaTeX (which also requires a ~1GB installation of a recent TeX distribution)
I won't mention the higher memory and CPU requirements when compiling the PDF file... ;-)
using TeX for PDF and Morris/g.raphaël/whatever for HTML of course means maintaining two interfaces for your data (have fun extracting that into a gem ;-))
It's more of an advanced task (not the Ruby/Rails part, but the LaTeX one), but if you value the high quality of TeX'ed documents, it's definitely the way you should go.
Using v8 on the other hand sounds far to nice to be true :-)
I worked with Java Swing for several years, several years ago, and have some comments and suggestions for those who want to take it further than the basic example you provided:
In my experience it's better practice not to call setVisible(true) when the frame is instantiated (that is, inside the class definition), but instead make it visible after it has been created. There may be other initializations you want to perform between the creation of the frame and the displaying of it, especially if it's happening at startup time.
An alternate way of instantiating a JButton is to pass it an instance of an Action class. This offers a cleaner separation between the visual button object and the business logic it executes. In addition, a single Action instance can be shared by multiple UI components. This comes in handy when you want the action to be triggerable by both a button and a menu item, for example. The UI components set themselves up as a listener to the action so that changing the enabled state of the action enables or disables all UI objects that use it.
It's a little cleaner to use Ruby-like property setter notation in the class, but make sure to preface the property with self. or else Ruby (any Ruby, not just JRuby) will consider it a local variable initialization. For example:
Normally it's necessary to call pack() on a JFrame after you've added all the components to it so that the frame will lay out its components properly. I guess it's not necessary with a single button.
You mention that in Java you would normally use an anonymous function for the behavior of an action listener, but I think you meant an anonymous class.
Using the JOptionPane show methods by themselves in a script without running a full fledged Swing program is a really great idea that never occurred to me. Thanks!
I would like to see something on the Russian doll technique that DHH often refers to too - perhaps with an update to the PJAX cast as well, as I think it's changed significantly since the episode that covered it.
Why put everything in a separate controller for API? Image a separate API registration controller and a standard web controller; changes are made to the web controller forgetting to make the same changes to the API controller.
This is the problem that the respond_to blocks are suppose to help solve.
Take a look at VersionCake ( https://github.com/bwillis/versioncake ); easily set the API version in the request header. The appropriate view is then rendered for the request (e.g. show.v1.json.jbuilder). If the requested version of the view doesn't exist, the next prior version is rendered ensuring backwards compatibility.
I'm having a similar issue. unicorn:restart doesn't seem to be reloading the unicorn process at all. However nothing to do with the assets, the actual start time on the process doesn't change.
Love your screencasts but just a tip. Im a newbie and it seems like almost every screencast leaves out one or two small little details that are taken for granted. For example, I tried to setup a nested form here following your tutorial exactly and I couldn't get the nested fields to show up. After much research I learned that I needed to build the nested attribute within the parent's controller NEW action. Once I did this, the fields showed up. You do not show this anywhere on your notes or anything and I think steps like these are taken for granted. My recommendation is that your show notes should be completely thorough and should be a complete working representation of the code to make it work. You go through the process of starting a new app in this video (which I think could be taken for granted), but you leave this part out (which should not). Anyways, thought this would help...
The memoization is per-request based. It's good when you want to call the same (heavy) methods many times in a request lifetime (for instance, current_user).
Hey Ryan,
thanks for this great screencast.
I have only one problem:
Is there any way to write a scope or maybe a query with arel to get all friends, own and inverse, in one query?
another thing that people might want to play around with is partial match. searching for 'jun' with the blog-after code will get
SELECT "articles".* FROM "articles" WHERE (to_tsvector('english', name) @@ to_tsquery('jun') or to_tsvector('english', content) @@ to_tsquery('jun')) ;
id | author_id | name | content | published_at | created_at | updated_at
----+-----------+------+---------+--------------+------------+------------
(0 rows)
where as the following will get Superman (content has the word june) and Robin (junior) as a result
SELECT "articles".* FROM "articles" WHERE (to_tsvector('english', name) @@ to_tsquery('jun:*') or to_tsvector('english', content) @@ to_tsquery('jun:*')) ;
also, there is an additional contrib, pg_trgm, that can help with partial searching:
Ryan, in the video you mention that the category_name method may not increase performance due to multiple reads from memcached however, couldn't this be combated through the use of memoization as you show in episode 137?
This is a read through and write through plugin for ActiveRecord.
It can cache normal find query or has_one/belongs_to query, even find by other unique index column.
Is there a way to disable friendly ID in development mode?
Thank you Alain. I had nested resources with comments for both resources, and this worked for me.
for example:
Order from deepest nested resource down.
Never mind. Works fine with Mongoid.
A comprehensible video!
Anyone got this working with mongoid?
if you want to get down into the nitty gritty and really focus on the formatting - perhaps take a look at Latex for rails, it was exactly what I was looking for.
index_by works a lot better after a group by query compard to group_by.
In #360 Ryan used this:
should be
I seperate crop-related.css from application.css, then it works.
After I setting enviorment from Development to Production, the jCrop seems not working correctly. It maybe the problem caused by precompiling and compressing. Any suggestions? Thx!
Sorry, I paid not enough attention to controller file. Everything works!
Hi guys, still have save url error with the latest Mercury version. Are there any solutions?
Great episode, thank you Ryan!
Hi,
Is there a way to use the same Facebook app for both production and development?
I mean, in FB app settings you can provide only one Site URL, which for development is usually http://localhost:3000/ and for production your actual URL where the application is hosted.
Of course you could create a separate "development facebook app" with a different APP ID and SECRET and localhost:3000 as login callback url, but it would be nice, if OmniAuth Facebook and the same fb app could handle both development and production.
Make sure that:
you're running it in JRuby (sorry but it happens ;) )
you've called
require 'java'
you've called
java_import 'com.dockyard.PgArrayParser'
you've compiled the class using
javac
the .class file, or a jar file that contains it, is in your classpath at runtime
if the class is in a class file, rather than in a .jar file, then it will need to be in a com/dockyard subdirectory of a directory in your classpath.
-- Keith
Everything was great up till the end when you did that markdown erb hack.
I agree about tilt, it would make things much easier.
Morris.js looks super simple to setup and use.
My line charts required logarithmic Y-axis. So I had to settle on the Google Visualization API with the Visualr Gem. However, over time, I found it somewhat rigid. Therefore, I had to go to HighCharts which can do just about everything that I need to do. As Ryan points out, it is a commercial product though.
Usually, I stick with LaTeX and PGF/TikZ to produce PDF graphs.
This has some disadvantages, though:
It's more of an advanced task (not the Ruby/Rails part, but the LaTeX one), but if you value the high quality of TeX'ed documents, it's definitely the way you should go.
Using v8 on the other hand sounds far to nice to be true :-)
Any thoughts about jqPlot?
Great episode another option is: Google Charts
What would you recommend for charts in both html and a generated pdf? Ever tried one of these libs with v8 on the server?
Ryan -
Nice presentation, and thanks for getting the word out about JRuby. I think it offers a lot of possibilities to supplement MRI Ruby.
Regarding using JRuby to write Swing apps, if anyone's interested in seeing a small but nontrivial JRuby Swing app, check out my Game of Life Viewer at [https://github.com/keithrbennett/life_game_viewer], blog article at [http://www.bbs-software.com/blog/2012/09/05/conways-game-of-life-viewer/].
Also, in many cases you can eliminate JRuby's JVM startup times by using Nailgun (blog article at [http://www.bbs-software.com/blog/2012/09/15/hello-nailgun-goodbye-jvm-startup-delays/).
And, for more information to supplement this JRuby screencast, you can check out [http://www.bbs-software.com/blog/2012/09/04/jruby-presentation-northern-virginia-ruby-user-group/].
I worked with Java Swing for several years, several years ago, and have some comments and suggestions for those who want to take it further than the basic example you provided:
In my experience it's better practice not to call
setVisible(true)
when the frame is instantiated (that is, inside the class definition), but instead make it visible after it has been created. There may be other initializations you want to perform between the creation of the frame and the displaying of it, especially if it's happening at startup time.An alternate way of instantiating a JButton is to pass it an instance of an Action class. This offers a cleaner separation between the visual button object and the business logic it executes. In addition, a single Action instance can be shared by multiple UI components. This comes in handy when you want the action to be triggerable by both a button and a menu item, for example. The UI components set themselves up as a listener to the action so that changing the enabled state of the action enables or disables all UI objects that use it.
It's a little cleaner to use Ruby-like property setter notation in the class, but make sure to preface the property with
self.
or else Ruby (any Ruby, not just JRuby) will consider it a local variable initialization. For example:Normally it's necessary to call
pack()
on a JFrame after you've added all the components to it so that the frame will lay out its components properly. I guess it's not necessary with a single button.You mention that in Java you would normally use an anonymous function for the behavior of an action listener, but I think you meant an anonymous class.
Using the JOptionPane show methods by themselves in a script without running a full fledged Swing program is a really great idea that never occurred to me. Thanks!
Cheers,
Keith
I am trying to add JRuby support to my C-extension gem, by writing a Java class and executing it when the gem is installed on JRuby.
NameError: cannot load Java class com.dockyard.PgArrayParser
Any suggestion?
thanks
Thanks!
@folivi In case you never found your solution, or for posterity in case other people find this comment while searching for this same solution
Make sure
authenticates_with_sorcery!
comes afterinclude Mongoid::Document
E.g.
Another great video Ryan!
I would like to see something on the Russian doll technique that DHH often refers to too - perhaps with an update to the PJAX cast as well, as I think it's changed significantly since the episode that covered it.
+1
thanks a lot for your awesome railscasts!
you're a superhero :)
greets from austria
Why put everything in a separate controller for API? Image a separate API registration controller and a standard web controller; changes are made to the web controller forgetting to make the same changes to the API controller.
This is the problem that the respond_to blocks are suppose to help solve.
Take a look at VersionCake ( https://github.com/bwillis/versioncake ); easily set the API version in the request header. The appropriate view is then rendered for the request (e.g. show.v1.json.jbuilder). If the requested version of the view doesn't exist, the next prior version is rendered ensuring backwards compatibility.
I'm having a similar issue. unicorn:restart doesn't seem to be reloading the unicorn process at all. However nothing to do with the assets, the actual start time on the process doesn't change.
Ryan -
Love your screencasts but just a tip. Im a newbie and it seems like almost every screencast leaves out one or two small little details that are taken for granted. For example, I tried to setup a nested form here following your tutorial exactly and I couldn't get the nested fields to show up. After much research I learned that I needed to build the nested attribute within the parent's controller NEW action. Once I did this, the fields showed up. You do not show this anywhere on your notes or anything and I think steps like these are taken for granted. My recommendation is that your show notes should be completely thorough and should be a complete working representation of the code to make it work. You go through the process of starting a new app in this video (which I think could be taken for granted), but you leave this part out (which should not). Anyways, thought this would help...
Wouldn't it be a good move to make the validation method private?
How expensive would this solution be if you have 100,000+ interactions a day on your site? Does this scale well?
Great!
The memoization is per-request based. It's good when you want to call the same (heavy) methods many times in a request lifetime (for instance,
current_user
).+1
Real time dashboard:
http://thechangelog.com/post/14865245126/fnordmetric-beautiful-
real-time-metrics-dashboard-powere
Hey Ryan,
thanks for this great screencast.
I have only one problem:
Is there any way to write a scope or maybe a query with arel to get all friends, own and inverse, in one query?
done ...
Cheers
Andy
another thing that people might want to play around with is partial match. searching for 'jun' with the blog-after code will get
where as the following will get Superman (content has the word june) and Robin (junior) as a result
also, there is an additional contrib, pg_trgm, that can help with partial searching:
http://www.postgresql.org/docs/9.1/interactive/pgtrgm.html
and can also do similarity.
like unaccent, pg_trgm is not built by default for a postgres install.
You might want to look at fuzzy matching
http://stackoverflow.com/questions/7730027/how-to-create-simple-fuzzy-search-with-postgresql-only
http://fuzzytolerance.info/using-fuzzy-search-in-postgresql/
http://www.postgresql.org/docs/9.1/interactive/contrib.html
"When building from the source distribution, these modules are not built automatically, unless you build the "world" target (see step 2)."
unaccent is not built by default for a postgres install. this might be the issue.
Ryan, in the video you mention that the category_name method may not increase performance due to multiple reads from memcached however, couldn't this be combated through the use of memoization as you show in episode 137?
You are a stud!
Yes you can.
This pull request enabled Fnordmetric to run as a rack app.
https://github.com/paulasmuth/fnordmetric/issues/5
However, keep an eye in your Redis Store. Depending on the amounts of events you might end running out of space in your Redis REALLY QUICKLY.
I ate a 100MB Redis Store in just 3 days (Hight traffic website).
Here is my password_resets controller code, in case this is still a problem:
def update
@user = User.find_by_password_reset_token!(params[:id])
@identity = Identity.find(@user.id)
if @user.password_reset_sent_at < 2.hours.ago
redirect_to new_password_reset_path, :alert => "Password ↵
reset has expired."
elsif @identity.update_attributes(params[:identity])
redirect_to root_url, :notice => "Password has been reset."
else
render :edit
end
end
It is simply an ActiveRecord object caching gem using Rails.cache methods.
This is a read through and write through plugin for ActiveRecord.
It can cache normal find query or has_one/belongs_to query, even find by other unique index column.
https://github.com/csdn-dev/second_level_cache
Excellent episode Ryan. I really enjoy the fact that you're including deployment related information in your latest videos.
Do you know of a gem that is similar to dalli for redis caching (for persistence)?