Javascript works fine without semi-colon, they're not necessary. It's not like you're gonna be modifying their javascript files. You can still use them in your javascript functions.
Can anyone point me in the right direction getting this to work with file uploading? I've tried just sort of mashing file uploading in there, but you can't store files in a session variable (you get type error, can't dump file).
Great Gem Ryan. Thank you!
I am trying to set up Private_Pub for my application.
I need to display a list of all the users who are online at a given time.
Any ideas how to do this???
I used this for an asset management app I'm writing.
Instead of countries/states, I use Makes/Models (which belong to an asset).
Anyway, if you are loading a record that has a make/model saved (or a country/state) then the model (state) will be hidden and you will have to change the make (country) to re-enable it. Then you will have to know it's saved value. So I changed it to only hide the model (state) if there is none saved.
what does "supposed to" mean in this context? "more subject to hacking?", "client side runs slower", etc.? Is there an actual technical downside, other than stylistic preferences?
p.s. I put my js curly braces on their own line. Cuz I'm a rebel and that's how I roll.
The screencast and what Ryan mentioned are indeed authentication because they help you keep trail of all activities for a digital identity. This is what most public websites need. But if you need some link between the physical person and digital id (for example to prevent 1 person from having multiple accounts) you can use an approval flow. Look at authentication gems such as devise. Devise allows you to mandate approval of new registration.
There are other strategies worth looking at too. For example, Google encourages people to link their account(s) to a mobile number. That way even if a person has multiple google accounts, they can be linked together via a common mobile number. You need to decide what works for your application.
It is not meant to be used for such forms (e.g. form_tag based forms which do not have an underlying model).
it is meant to be used for the forms which are connected to an underlying data table which happens to be majority of forms for a CRUD based Rails application.
Use the column name with a table alias, for example: 'us.name'.
In the controller, always retrieve info joining the other table, with its alias 'Product.joins('JOIN table alias ON field = field')'
And then use as the column name, the alias + the column name, as I stated before.
And remember to include this 'special' name in the valid column names in the sort_column private method.
The jruby-rack-worker gem comes to the rescue: http://github.com/kares/jruby-rack-worker. It lets you still use delayed_job to schedule jobs, but provides a different way to kickoff worker processes that is more friendly to JRuby and also works on a windows tomcat server. I'm not advocating deploying on windows, but if you're forced to do that for some reason and you also need to use JRuby -- take a look at jruby-rack-worker.
In Rails 3.1 there is a nicer way to handle conditional attr_accessible calls. See this blog entry.
The argument over Rails' default permissions for mass assignment was reignited after GitHub was hacked on March 4, 2012.
A Russian GitHub user, Egor Homakov, was arguing for more restrictive defaults, but he was rebuffed over a three day period. To make his point, he exploited this weakness on GitHub, where some model attributes were not protected in the code that handles public key submissions, in order to submit this commit to the rails master branch.
As a result, several commits were made to make whitelisting of model attributes the default behavior of rails generators. We will see if these modifications actually make it to the next release of Rails.
for some reason, I just removed ":cache => true" from my application.html.erb file and the problem went away. When I did have it I kept getting a "wrong number of arguments (3 for 2)" error that pointed to line #6:
<%= javascript_include_tag "jquery","application", :cache=>true %>
in application.html.erb.
I still cant figure out whey this was breaking the app!
hi everybody,
i use will_pagine to navigate through a long table. how do will_paginate remember the checked checkboxes.
I need your help
thanks in advance
I had to use database_cleaner to clean up my testing database before each test:
ruby
require 'database_cleaner'DatabaseCleaner.strategy = :truncationclassMiniTest::Spec
before :eachdoDatabaseCleaner.clean
endend
This does not use transactions, although it should be possible somehow with database_cleaner. They have an RSpec example on their GitHub page which maybe could work.
Ryan could have done this because it's more Ruby 1.9 to omit the hash rocket now and personally I think his syntax is looking cleaner.
But you're right that the as: option is unnecessary.
I added rack-pjax and it works but there is always an extra "&" at the end of the URL shown in browser bar even if my link doesn't have it. This breaks my link_to_unless ...
If I remove
$('.navbar a').pjax('[data-pjax-container]')
from my .js.coffee file, the & goes away.
Example link I use in my application navbar
<%= link_to_unless(params[:category].to_s == "Application", "Application", {:controller => "top10", :action => "index", :category => "Application"}) %>
In Chrome 17, when I hover this link, it shows
http://localhost:3000/top10?category=Application
but when I click it, the current URL in the top Chrome bar is
http://localhost:3000/top10?category=Application&
DelayedJob doesn't seem to work with JRuby unfortunately, at least not on windows -- as best I can tell. It will queue jobs, but starting a background job fails.
been using this for a while myself, along with flutie, also by thoughtbot
I second using bootstrap-sass. I supports the current version of Bootstrap and makes it so much easier to customize.
travis-ci told me that it works on all rubies, jrubies and rbxes
anyone know how to make jbuilder pretty print?
Nevermind, accidentally had two bootstrap gems included (one based on 1.4 and one based on 2.0) and the wrong version was included.
How can I add my own icon sprite? I see we're setting the variable here:
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
However, where in my project would I put my "icon-sprite.png" file. There's no twitter/bootstrap folder anywhere.
Thank you.
Javascript works fine without semi-colon, they're not necessary. It's not like you're gonna be modifying their javascript files. You can still use them in your javascript functions.
+1
When I call entries.create my Rails app logs a GET request to /api/entries instead of a POST with params. Saving an updated entry works just fine.
I'm even getting this behavior running the railscast code from github.
Should I be using a different server than webrick?
Can anyone point me in the right direction getting this to work with file uploading? I've tried just sort of mashing file uploading in there, but you can't store files in a session variable (you get type error, can't dump file).
hmm, you could use wordnet in order to extract synonyms and hypernyms and add them to the search
Very interesting!
Good question, I am currently having the same problem.
great. but when I typed "mongo" in the search box on the main page I can not find this episode (
Windows has an embedded runtime which can be used by execjs, you don't need to specify anything, it should just work.
You can use the pry-rails gem to automatically use pry as the Rails console.
Great Gem Ryan. Thank you!
I am trying to set up Private_Pub for my application.
I need to display a list of all the users who are online at a given time.
Any ideas how to do this???
I'm having trouble getting the navbar working. I'm using bootstrap-sass, haml and simple_form. What could be wrong?
Here is a screenshot of what is happening
It's like some of the CSS is not applied.
I used this for an asset management app I'm writing.
Instead of countries/states, I use Makes/Models (which belong to an asset).
Anyway, if you are loading a record that has a make/model saved (or a country/state) then the model (state) will be hidden and you will have to change the make (country) to re-enable it. Then you will have to know it's saved value. So I changed it to only hide the model (state) if there is none saved.
I also used parent().parent() because I am using with SimpleForm
what does "supposed to" mean in this context? "more subject to hacking?", "client side runs slower", etc.? Is there an actual technical downside, other than stylistic preferences?
p.s. I put my js curly braces on their own line. Cuz I'm a rebel and that's how I roll.
I just read a 37signals post on their caching technique in Basecamp Next and came here for some informations about partial-caching etc.
I think David explains very well, how you can use a technique like this very smart, to get fast responses: http://37signals.com/svn/posts/3112-how-basecamp-next-got-to-be-so-damn-fast-without-using-much-client-side-ui
@lazylester - you probably got an answer already.
The screencast and what Ryan mentioned are indeed authentication because they help you keep trail of all activities for a digital identity. This is what most public websites need. But if you need some link between the physical person and digital id (for example to prevent 1 person from having multiple accounts) you can use an approval flow. Look at authentication gems such as devise. Devise allows you to mandate approval of new registration.
There are other strategies worth looking at too. For example, Google encourages people to link their account(s) to a mobile number. That way even if a person has multiple google accounts, they can be linked together via a common mobile number. You need to decide what works for your application.
I hope that helps.
It is not meant to be used for such forms (e.g. form_tag based forms which do not have an underlying model).
it is meant to be used for the forms which are connected to an underlying data table which happens to be majority of forms for a CRUD based Rails application.
This has nothing to do with Ruby. Ruby was never ment to have semicolons. JavaScript is supposed to have semicolons at the end.
jayeshmori, Ben,
My way to solve that issue:
Use the column name with a table alias, for example: 'us.name'.
In the controller, always retrieve info joining the other table, with its alias 'Product.joins('JOIN table alias ON field = field')'
And then use as the column name, the alias + the column name, as I stated before.
And remember to include this 'special' name in the valid column names in the sort_column private method.
Hope it helps!
How would SimpleForm work with a form that isn't associated with an object? For example, a login form.
I'm having problems getting the gem to work with a rails 3.2.2:
undefined method `ends_with?' for #<Pathname:0x00000105898040> (NoMethodError)
The jruby-rack-worker gem comes to the rescue: http://github.com/kares/jruby-rack-worker. It lets you still use delayed_job to schedule jobs, but provides a different way to kickoff worker processes that is more friendly to JRuby and also works on a windows tomcat server. I'm not advocating deploying on windows, but if you're forced to do that for some reason and you also need to use JRuby -- take a look at jruby-rack-worker.
Does anyone know how to put the flash messages back in Rails 3.2.1??
<%= debug flash %>
is empty.I'm using that now, it works like a charm and saves a lot of markup :)
You can have SimpleForm to generate those wrappers by default, so you won't clutter your views with styles.
The docs are really easy to read, well written.
https://github.com/plataformatec/simple_form
In Rails 3.1 there is a nicer way to handle conditional attr_accessible calls. See this blog entry.
The argument over Rails' default permissions for mass assignment was reignited after GitHub was hacked on March 4, 2012.
A Russian GitHub user, Egor Homakov, was arguing for more restrictive defaults, but he was rebuffed over a three day period. To make his point, he exploited this weakness on GitHub, where some model attributes were not protected in the code that handles public key submissions, in order to submit this commit to the rails master branch.
As a result, several commits were made to make whitelisting of model attributes the default behavior of rails generators. We will see if these modifications actually make it to the next release of Rails.
how woud someone use simple form to generate something like below. As you can see the input is wrapped with a div.
Please have a look on my project, I've fork the seyhunak project to use directly the official source of bootstrap.
So each time twitter bootstrap is updated you can get it directly in your rails project!
https://github.com/keysen/twitter-bootstrap-rails
Thanks Ryan !!
Unfortunately if the app uses one dyno 24x7, the app cannot use the free quota for the worker as well. :/
Hey Nuno, I created a tool to help people to test HTML e-mails.
The tool, called Puts Mail uses Premailer to check HTML warnings and to make the CSS inline. ;)
But I think that your concern is more about the screencast Sending HTML Email, no?
Cheers,
Pablo Cantero
for some reason, I just removed ":cache => true" from my application.html.erb file and the problem went away. When I did have it I kept getting a "wrong number of arguments (3 for 2)" error that pointed to line #6:
<%= javascript_include_tag "jquery","application", :cache=>true %>
in application.html.erb.
I still cant figure out whey this was breaking the app!
Do you use semicolons in ruby, too? scnr
thanks!!!! I had the same problem
Irrelevant for 3.2.2, rails bug or API change?
hi everybody,
i use will_pagine to navigate through a long table. how do will_paginate remember the checked checkboxes.
I need your help
thanks in advance
Anyone else getting javascript errors with the Sass variation, i.e.
"$("a[rel=popover]").popover is not a function
[Break On This Error]
$("a[rel=popover]").popover();"
Looks like for some reason the bootstrap js files aren't getting served up.
I had to use database_cleaner to clean up my testing database before each test:
This does not use transactions, although it should be possible somehow with database_cleaner. They have an RSpec example on their GitHub page which maybe could work.
Ryan could have done this because it's more Ruby 1.9 to omit the hash rocket now and personally I think his syntax is looking cleaner.
But you're right that the as: option is unnecessary.
I added rack-pjax and it works but there is always an extra "&" at the end of the URL shown in browser bar even if my link doesn't have it. This breaks my link_to_unless ...
If I remove
$('.navbar a').pjax('[data-pjax-container]')
from my .js.coffee file, the & goes away.
Example link I use in my application navbar
<%= link_to_unless(params[:category].to_s == "Application", "Application", {:controller => "top10", :action => "index", :category => "Application"}) %>
In Chrome 17, when I hover this link, it shows
http://localhost:3000/top10?category=Application
but when I click it, the current URL in the top Chrome bar is
http://localhost:3000/top10?category=Application&
Any idea ?
Thanks
You can also set
config.active_record.whitelist_attributes = true
in config.You can pass a block to
f.input
orf.association
call and use rails form helpers there like this:Doing so, you get simple_form's, label, hint and other stuff, but overwrite only the actual input to the one you need.
DelayedJob doesn't seem to work with JRuby unfortunately, at least not on windows -- as best I can tell. It will queue jobs, but starting a background job fails.
Nevermind, my validations were failing because I had filtered them to only occur
:on => :create
.