I wanted a more compact log file, with additional information (timestamp and log level, for instance), and more control over colorization. Since none of the existing logging plugins did quite what I wanted, I wrote one. It's here:
Just in case someone is interested to know, in Ubuntu versions 11.10 (Oneiric Ocelot) and onwards the "admin" group is not going to be provided by default. The power that be are favouring the "sudo" group instead of "admin" group. If you're upgrading from a lower version, your "admin" group will persist but on a fresh install "admin" group will be missing.
So if you get an error that "admin" group does not exist, simply replace it with "sudo".
After applying :primary => true, I am getting this error
console
ritesh-ranjans-MacBook-Pro:learnbooksignup riteshranjan$ cap deploy:setup
./config/deploy.rb:28:in`load': compile error (SyntaxError)
./config/deploy.rb:23: syntax error, unexpected ':', expecting kEND
task command, roles: :app, except: {no_release: true} do
^
./config/deploy.rb:23: odd number list for Hash
task command, roles: :app, except: {no_release: true} do
^
./config/deploy.rb:28: syntax error, unexpected ':', expecting $end
task :setup_config, roles: :app do
^
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:89:in `load'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:86:in`load'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:86:in `each'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:86:in `load'
from Capfile:5:in`load'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:89:in `load'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:86:in`load'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:86:in `each'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/configuration/loading.rb:86:in `load'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/cli/execute.rb:65:in`load_recipes'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/cli/execute.rb:65:in `each'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/cli/execute.rb:65:in `load_recipes'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/cli/execute.rb:31:in`execute!'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/lib/capistrano/cli/execute.rb:14:in `execute'
from /Library/Ruby/Gems/1.8/gems/capistrano-2.12.0/bin/cap:4
from /usr/bin/cap:19:in `load'
from /usr/bin/cap:19
I've built a more colorful formatter. This code might be not optimized yet, since I didn't investigate the type of severity (nor did I for Logger::Severity::DEBUG and friends).
Maybe you'll find it useful, too ;-)
log_formatter.rb
classLogger::SimpleFormatter# from activesupport/lib/active_support/core_ext/logger.rbdefcall(severity, time, progname, msg)
"#{severity_color severity}#{String === msg ? msg : msg.inspect}\n"end
private
defseverity_color(severity)
case severity
when"DEBUG""\033[0;34;40m[DEBUG]\033[0m"# bluewhen"INFO""\033[1;37;40m[INFO]\033[0m"# bold whitewhen"WARN""\033[1;33;40m[WARNING]\033[0m"# bold yellowwhen"ERROR""\033[1;31;40m[ERROR]\033[0m"# bold redwhen"FATAL""\033[7;31;40m[FATAL]\033[0m"# bold black, red bgelse"[#{severity}]"# noneendendend
Anyone have any tips for testing this thing? If you test the ProductsDatatable class on it's own (rather than testing the results of the products/index controller action) how can you instantiate a view_context on initialization? Or is it best to just rely on mocking/stubbing everything that would normally exist in the context of a normal request?
Looking back to the Presenters from Scratch screencast looks like it might be something like this?
ruby
classProductDatatableTest < ActionView::TestCase
test "something or other"do
datatable = ProductDatatable.new(view)
# but, how to set the params for the view?endend
Internally, active admin uses devise, so you can go as far as just doing away with active admin's devise config, by replacing the following code in your routes.rb file.
Yep your correct. I probably didn't word my question very well.
Since the root user doesn't have access to ssh you cant rsync the files to /var/chef so I have to figure out a work around for that. I don't think enabling the root user is a good option.
Don't test rails internals. Instead do something like
it "must have a products collection" do
@topic.must_respond_to :products
@topic.products.class.must_equal Array
@topic.products.size.must_be :>=, 1
@topic.products[0].class.must_equal Product
end
In these assertions you verify:
The @topic instance has access to the products collection
The collection is an array
The collection has elements
The collection's first element has a class of Product
Always test the expected result, and not the internal mechanisms. Test API and you will find that many of your testing issues vanish.
Hello John. Sorry for the late reply, didn't notice your question until now. If it's still a problem, make sure you're actually installing the gem on Heroku. By default, Heroku does not install gems from the assets group in your Gemfile, as they're considered only for development and test. So, if your gem is in the assets group, try moving it out of there and see if the problem persists.
I know it is rather controversial but I found RubyMine IDE to be a great way to debug rails apps. It has very cool UI for debugger with breakpoints, visual stack and so forth.
Here is the solution, which allows avoid rendering partial into markup. templates become available directly in javascript SMT (shared mustache template) global object. https://github.com/railsware/smt_rails
Can anyone share an Apache2 config block that directs Apache to serve the static gzipped assets like nginx? The Rails guide is short on the topic...and my skills with setting up Apache config files are not good.
Oh, and there is a good writeup on SO that shows how to package up your assets to serve on a conditional basis (e.g., to specific versions of ie, etc.)
After two days of trying to figure out why my app suddenly broke (it used to work before), I found your reply here and I have the exact same issue!
Before this worked:
haml
- for project in @projects.models
%a{ href: "/project/#{project.get('slug')}" }= project.get('name')
But after some more working on the app, and updating gems (which I suspect broke things), I had to replace it with this to continue working:
haml
- for project in @projects.models
%a{ href: "/project/#{project.get('project').slug}" }= project.get('project').name
I suspect something changed in a recent Backbone.js update or it has something to do with Rails' include_root_in_json options (but I tried both false and true, no dice).
A decent number of large users are not using chef-solo and there are definitely approaches that you can take to resiliency with the chef-server infrastructure.
Obviously Engine Yard is one of the poster children of chef-solo but last time I spoke to anyone from over there, they are also still on 0.6.x whereas the rest of the world has largely moved onto much newer releases. They're probably not the best example of a "large scale" user unless your needs marry closely with what they wanted.
Speaking personally, the benefits provided by Search are more than worth any hassle involved in making sure the API calls always get answered!
I think Ryan mentioned that you can do that to keep the controller clean. I implemented this a couple of weeks ago, and I wish the screencast came out earlier; I would have followed his suggestion.
A note to the readers: If you try to run the sample app using the episode code from github, you will get an error when you click on the "product name" link. This is because the show view is referencing the category model but there is none in the current code base. So just delete the offending lines of code that references the @product.category.name field.
me 2
I wanted a more compact log file, with additional information (timestamp and log level, for instance), and more control over colorization. Since none of the existing logging plugins did quite what I wanted, I wrote one. It's here:
https://github.com/bmc/grizzled-rails-logger
It works with the existing
ActiveSupport::BufferedLogger
, instead of replacing it, so it should still work with new features like tagged logging.Comments and criticisms are welcome. And, of course, feel free to adapt, hack, or otherwise steal.
nice episode, but the problem that the last second or something gets cut off from the video is still there (all videos so far)
Very nice episode. I bought the subscription just to watch it, and it didn't disappoint. Keep up the good work!
Thanks for that information, Glenn. You said "should suffice" — did you have a chance to test that theory? Does it work?
+1
Just in case someone is interested to know, in Ubuntu versions 11.10 (Oneiric Ocelot) and onwards the "admin" group is not going to be provided by default. The power that be are favouring the "sudo" group instead of "admin" group. If you're upgrading from a lower version, your "admin" group will persist but on a fresh install "admin" group will be missing.
So if you get an error that "admin" group does not exist, simply replace it with "sudo".
adduser deployer --ingroup sudo
nice!
After applying :primary => true, I am getting this error
would be useful to have the Gemfile in the user notes as well
I am on windows and i am getting the following error when i tried to sign up
"NoMethodError in UsersController#new
undefined method `key?' for nil:NilClass"
I am using rails 3.2.3
I've built a more colorful formatter. This code might be not optimized yet, since I didn't investigate the type of
severity
(nor did I forLogger::Severity::DEBUG
and friends).Maybe you'll find it useful, too ;-)
Nice and concise - thank you Ryan!
Anyone have any tips for testing this thing? If you test the ProductsDatatable class on it's own (rather than testing the results of the products/index controller action) how can you instantiate a
view_context
on initialization? Or is it best to just rely on mocking/stubbing everything that would normally exist in the context of a normal request?Looking back to the Presenters from Scratch screencast looks like it might be something like this?
If I can get some attention or upvotes, you'll help stamp out ruby-debug19 from the Rails Gemfile template https://github.com/rails/rails/pull/5835
Give this a try
Sweet! Getting rid of assets requests is a priority for me. Short and sweet; thanks.
The simplest method is to copy the
app/views/active_admin/devise/sessions/new.html.erb
file (you can find it here https://github.com/gregbell/active_admin/blob/master/app/views/active_admin/devise/sessions/new.html.erb) to your application directory, then just make any changes that you might need.Internally, active admin uses devise, so you can go as far as just doing away with active admin's devise config, by replacing the following code in your
routes.rb
file.And updating
config/initializers/active_admin
as you see fit.Yep your correct. I probably didn't word my question very well.
Since the root user doesn't have access to ssh you cant rsync the files to /var/chef so I have to figure out a work around for that. I don't think enabling the root user is a good option.
Thanks man! Saved a lot of time for me.
Wow, how have I never learned the
t
command on github before... Thanks for the tip Ryan!BTW, Ryan, whats up with the end of the video. You started to answer the question of whether or not this will move you off of rspec.
I did the switch awhile back from rspec to riotrb, and got so used to fast tests, I dumped rspec altogether. Then I dumped riotrb for minispec.
Havent looked back
Don't test rails internals. Instead do something like
In these assertions you verify:
Always test the expected result, and not the internal mechanisms. Test API and you will find that many of your testing issues vanish.
I am using the mongoid data table gem that has a one stop search functionality https://github.com/potatosalad/mongoid-data_table
Hello John. Sorry for the late reply, didn't notice your question until now. If it's still a problem, make sure you're actually installing the gem on Heroku. By default, Heroku does not install gems from the
assets
group in your Gemfile, as they're considered only for development and test. So, if your gem is in theassets
group, try moving it out of there and see if the problem persists.Good luck. :-)
thank you but i have a loop :( don't know why
Yeah, I've banged my head on it!
Let we know as soon as a fix for that will be available.
By now, I'm using the patch suggested here:
https://github.com/svenfuchs/globalize3/issues/128
Thank you!
See this article in my blog
I know it is rather controversial but I found RubyMine IDE to be a great way to debug rails apps. It has very cool UI for debugger with breakpoints, visual stack and so forth.
Hello,
Just a remark on the screencast.
Apparently, you need to use
config.include FactoryGirl::Syntax::Methods
rahter than
config.include Factory::Syntax::Methods
Here is the solution, which allows avoid rendering partial into markup. templates become available directly in javascript SMT (shared mustache template) global object.
https://github.com/railsware/smt_rails
It would be great if you could show how to use the asset pipeline, but use s3 or rackspace to serve the assets
I've just set up a site using the pipeline and SSL - you've got to make sure you use the image_tag helper and protocol relative paths:
http://collectiveidea.com/blog/archives/2010/11/29/ssl-with-rails/
Nice 'cast...
Can anyone share an Apache2 config block that directs Apache to serve the static gzipped assets like nginx? The Rails guide is short on the topic...and my skills with setting up Apache config files are not good.
Oh, and there is a good writeup on SO that shows how to package up your assets to serve on a conditional basis (e.g., to specific versions of ie, etc.)
http://stackoverflow.com/questions/7134034/using-rails-3-1-assets-pipeline-to-conditionally-use-certain-css
Thanks!
I am also getting the same error. please someone help...
After two days of trying to figure out why my app suddenly broke (it used to work before), I found your reply here and I have the exact same issue!
Before this worked:
But after some more working on the app, and updating gems (which I suspect broke things), I had to replace it with this to continue working:
I suspect something changed in a recent Backbone.js update or it has something to do with Rails'
include_root_in_json
options (but I tried bothfalse
andtrue
, no dice).I just released a ruby gem to integrate normalize.css with the asset pipeline.
https://github.com/markmcconachie/normalize-rails
Too complicated for a simple app :(
A decent number of large users are not using chef-solo and there are definitely approaches that you can take to resiliency with the chef-server infrastructure.
Obviously Engine Yard is one of the poster children of chef-solo but last time I spoke to anyone from over there, they are also still on 0.6.x whereas the rest of the world has largely moved onto much newer releases. They're probably not the best example of a "large scale" user unless your needs marry closely with what they wanted.
Speaking personally, the benefits provided by Search are more than worth any hassle involved in making sure the API calls always get answered!
I think Ryan mentioned that you can do that to keep the controller clean. I implemented this a couple of weeks ago, and I wish the screencast came out earlier; I would have followed his suggestion.
I'm having a bunch of trouble trying to make this work beyond what has been said on both screencasts.
I'm simply trying to make a full CRUD, like Rails scaffold, just work. But I'm getting bite by loading times and page rendering.
Anybody else having such problems?
Got Rails 3.2 here and no problems at all. Maybe this?
Asset Pipeline can be a little annoying if additional js/css other than application.{js,css} is required.
For example, with active_admin enabled, config/environments/production.rb needs a little change:
config.assets.precompile += %w( active_admin.js active_admin.css )
I would like to have this precompile array automatically set, but no good solution yet.
Why do you create a Class when you can create the json in the respond_to block? For example:
I made a gem to do this a while back -- cuts out most of the heavy lifting: https://github.com/jasondew/data_table
THere is a a way to get ruby-debug working on ruby 1.9.3
put this in your gemfile
I found this at Stackoverflow
Great
I have trouble with assets and ssl in production . Anybody knows if is it a known issue?
Nnz
Did you figure this out? I'm having the same problem...
A note to the readers: If you try to run the sample app using the episode code from github, you will get an error when you click on the "product name" link. This is because the show view is referencing the category model but there is none in the current code base. So just delete the offending lines of code that references the @product.category.name field.
In my AWS server I need to use "ubuntu" server instead as the root user is disabled.