If anyone are looking for a way to exclude new tables from the multitenant migration (i.e. Only create the new table in the public schema). This solved the problem for me:
ruby
ifActiveRecord::Base.connection.current_schema == 'public'Your migration
end
for Rails 4.0, I think the turbolinks get in the way of allowing the header to refresh in some browsers. i.e. following this railscast when I clicked on the mobile/full site link, the css would not change unless I would do a page refresh in internet explorer and firefox (no problem with ipad though...). so I put in the body html tag data-no-turbolink in views/layouts/application.html.erb, and works great now. yepi.
Maybe a silly question. I am using ubuntu 12.04 so the bootstrap for 10.04 just isn't needed. right? :) So far I just skipped that part because I figured it isn't needed. I just wanted to make sure I am not missing something by not using it.
Don't use Active Record but create an SQL statement so the data insert is done in a single statement:
ruby
inserts = []
loop around your data do |line|
inserts.push("('#{Time.now}'::timestamp, \
'#{Time.now}'::timestamp,'#{line[0]}','#{line[1]}', \
#{current_user.id})")
end
sql_query = "INSERT INTO table_name (created_at,updated_at,attribute1, attribute2,user_id,) VALUES #{inserts.join(", ")}"ActiveRecord::Base.connection.execute sql_query
This will take each array element and joins them with a comma to have a long single sql statement which is then executed. Make sure you don't have any single quotes in your incoming data. When using postgres you can replace them with two single quotes '' to allow them to be used as attribute values.
For what it's worth, if you want to use Torquebox (I heart Torquebox) but want the hands off style of infrastructure that you can get with Heroku it might be worth it to check out OpenShift from RedHat.
It's very similar to Heroku but a little more flexible for your configuration needs. It's worth noting that it's also in the same Amazon data center that Heroku resides in, so any 3rd party services or databases should be able to connect just as easily within the network.
I was able to get everything working, but I've discovered a quirk that I can't seem to figure out. When you click sign out, the fb-root div inserted by facebook.js.coffee.erb disappears. That means if you sign in again immediately, you'll be redirected to Facebook instead of getting the pop-up window. Reloading the page makes it reappear, but it would be nice to get it to behave consistently. I'm using rails 4 if it matters.
This is great and works on local, but throws a 500 on production for some reason. I'm thinking it has something to do with what he mentions around ~08:09
"... In a real application you'll want to check the entire path to make sure that the parents are correct"
and then he talks about the shortcut method. Any ideas for what the non-shortcut method would be? I have a Node model I would like to be invisible as parent
Hi, I am newbie in rails.
I am trying to use ElasticSearch. But when I run rake db:setup, I don't see my articles any more. I guess the data is not loaded from seeds.rb. How can I solve that problem?
Fuck Devise, Sorcery is way much cooler. Or easier perhaps. I don't want to go thru all the twinge I've been spending my whole afternoon figuring out how to work my way with Devise. And by the way, this is the simplest by far, I know it's outdated but it only gets better and improved by time. I'm good to go with this, 'Sorcery'.
I've developed a method called group_date that is added to ActiveRecord::Relation.
You can read about it in this gist: https://gist.github.com/leods92/7164159
Have you tried calling #build as you mention? That seemingly innocent change somehow sends me into an infinite recursive loop; that is to say, link_to_add_fields gets called over and over again. I can't imagine how building the new object through the association would have this side effect. Here is the line of code before the change:
It's worth noticing that the code presented in the video causes unexpected timezone issues.
As timestamps are stored in UTC when you use SQL's date() function you'll get the date in UTC which can be different. E.g (consider -0300 the local zone) 2013-12-01 01:00 -0300 -> (stored as) 2013-11-30 22:00 UTC => (after date()) 2013-11-30 when you'd expect 2013-12-01.
Rails makes conversions itself when fetching a timestamp column but since you're grouping in SQL Rails cannot do anything about it.
I'm still searching about this and if I find a optimal solution I'll post here.
My CSV file contains this type of symbol ᅠ and when i tried to import this file, the place of ᅠ is replaced with ? i.e, question mark and gets stored in database.
For example if this text is in my csv file "ᅠDinesh", upon import it gets stored as "?Dinesh".
Please help me out.
sorry to bother you guys again. I got to the very end with everything working, but now receiving Stripe::InvalidRequestError in SubscriptionsController#create
Anyone have any tips for adding a foreign key? Say in Ryan's example, Factory had many Products, and one wanted to upload Products from a CSV that did not contain a foreign key to the Factory each Product belonged to. Thanks!
great tutorial. I setup the subscription part and before integrating the stripe part, I want to add an association to the user. I have a user model with devise and want people to create a user account before being able to make a subscription. The problem is, that I am confused on how to get the user_id into the subscription. Can someone help?
I have followed the Ryan's code and copy-pasted all the codes, but
the css style @media print{} is not affecting to the pdf file so I cannot hide the link. I have tested with Chrome, IE and Firefox. Link disappears when I click browser's print preview.
If anyone are looking for a way to exclude new tables from the multitenant migration (i.e. Only create the new table in the public schema). This solved the problem for me:
Complete example
for Rails 4.0, I think the turbolinks get in the way of allowing the header to refresh in some browsers. i.e. following this railscast when I clicked on the mobile/full site link, the css would not change unless I would do a page refresh in internet explorer and firefox (no problem with ipad though...). so I put in the body html tag data-no-turbolink in views/layouts/application.html.erb, and works great now. yepi.
Also in Rails 4, remember to add the _destroy method to permitted params. Like this:
you also need to add it in the QuestionsController
@grammakov: You are a bloody lifesaver! Thanks for posting rails 4 compatible code.
Maybe a silly question. I am using ubuntu 12.04 so the bootstrap for 10.04 just isn't needed. right? :) So far I just skipped that part because I figured it isn't needed. I just wanted to make sure I am not missing something by not using it.
thanks @lucascioffi
Thanks for the useful screencast! Just wondering two things.
Is there any way to enable server side file size validation like: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Validate-attachment-file-size
Client side resizing doesn't seem to work for me.
https://github.com/blueimp/jQuery-File-Upload/wiki/Client-side-Image-Resizing
Does anyone have ideas?
Don't use Active Record but create an SQL statement so the data insert is done in a single statement:
This will take each array element and joins them with a comma to have a long single sql statement which is then executed. Make sure you don't have any single quotes in your incoming data. When using postgres you can replace them with two single quotes '' to allow them to be used as attribute values.
in your controller:
def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }
format.pdf { render :layout => false }
end
end
in your controller:
def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }
format.pdf { render :layout => false }
end
end
Hi,
I tried
But i get the following error.
wrong number of arguments (3 for 2)
For what it's worth, if you want to use Torquebox (I heart Torquebox) but want the hands off style of infrastructure that you can get with Heroku it might be worth it to check out OpenShift from RedHat.
It's very similar to Heroku but a little more flexible for your configuration needs. It's worth noting that it's also in the same Amazon data center that Heroku resides in, so any 3rd party services or databases should be able to connect just as easily within the network.
https://github.com/openshift-quickstart/torquebox-quickstart
its 2013 and this screencast is still actual
The calendar is working great but when i deploy it (using Heroku), the current date is wrong. It's set to a day ahead. What's wrong??
I am new to rails and i find these gems VERY VERY useful, thanks a lot!!!!
Yes. That would be great. I am facing the same issue now on EC2. Do you know of any workaround?
just tested it on my localhost
After you run
whenever --update-crontab
Go and edit the crontab (using crontab -e)
And replace production with development.
Note: You have to do this change every time you update the crontab.
Same deal with me. In devise.rb, I just use:
config.omniauth :twitter, "key-xxxxxxxxxxxxxxx", "secret-xxxxxxxxxxxxxxxx"
Try this:
I have the same problem :(
I was able to get everything working, but I've discovered a quirk that I can't seem to figure out. When you click sign out, the fb-root div inserted by facebook.js.coffee.erb disappears. That means if you sign in again immediately, you'll be redirected to Facebook instead of getting the pop-up window. Reloading the page makes it reappear, but it would be nice to get it to behave consistently. I'm using rails 4 if it matters.
How to use " More Like This " in ElasticSearch ?
+1
I was able to resolve this thanks to all that contributed to this
Thanks Ryan , I find it's very useful to use it with rolify gem
https://github.com/EppO/rolify
https://github.com/EppO/rolify/wiki/Tutorial
This is great and works on local, but throws a 500 on production for some reason. I'm thinking it has something to do with what he mentions around ~08:09
"... In a real application you'll want to check the entire path to make sure that the parents are correct"
and then he talks about the shortcut method. Any ideas for what the non-shortcut method would be? I have a Node model I would like to be invisible as parent
After creating a new migration, I always run:
which propagates any migrations to both development and test environments equally
Great railscast, thanks!
However
gem install vagrant
only resulted in downloading vagrant version 1.0.7, which is way out of date
and gave me many mysterious errors.
the best way to install vagrant is from binary installer from:
http://downloads.vagrantup.com/
Hi, I am newbie in rails.
I am trying to use ElasticSearch. But when I run rake db:setup, I don't see my articles any more. I guess the data is not loaded from seeds.rb. How can I solve that problem?
I would like to see this too.
Solution at http://stackoverflow.com/questions/19441535/jquery-file-upload-in-rails-4
Fuck Devise, Sorcery is way much cooler. Or easier perhaps. I don't want to go thru all the twinge I've been spending my whole afternoon figuring out how to work my way with Devise. And by the way, this is the simplest by far, I know it's outdated but it only gets better and improved by time. I'm good to go with this, 'Sorcery'.
I've developed a method called
group_date
that is added to ActiveRecord::Relation.You can read about it in this gist: https://gist.github.com/leods92/7164159
Nevermind. I found where the recursion was happening...
I added the following to development.rb:
Have you tried calling #build as you mention? That seemingly innocent change somehow sends me into an infinite recursive loop; that is to say, link_to_add_fields gets called over and over again. I can't imagine how building the new object through the association would have this side effect. Here is the line of code before the change:
after:
Any ideas?
It's worth noticing that the code presented in the video causes unexpected timezone issues.
As timestamps are stored in UTC when you use SQL's
date()
function you'll get the date in UTC which can be different. E.g (consider -0300 the local zone) 2013-12-01 01:00 -0300 -> (stored as) 2013-11-30 22:00 UTC => (afterdate()
) 2013-11-30 when you'd expect 2013-12-01.Rails makes conversions itself when fetching a timestamp column but since you're grouping in SQL Rails cannot do anything about it.
I'm still searching about this and if I find a optimal solution I'll post here.
Great Railscast, Ryan :+1:
My CSV file contains this type of symbol ᅠ and when i tried to import this file, the place of ᅠ is replaced with ? i.e, question mark and gets stored in database.
For example if this text is in my csv file "ᅠDinesh", upon import it gets stored as "?Dinesh".
Please help me out.
sorry to bother you guys again. I got to the very end with everything working, but now receiving Stripe::InvalidRequestError in SubscriptionsController#create
my error highlighted this.
customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)
Try this, it worked for me.
http://stackoverflow.com/questions/17719660/rails-4-csv-import-and-setting-a-value-to-a-key-value
Anyone have any tips for adding a foreign key? Say in Ryan's example, Factory had many Products, and one wanted to upload Products from a CSV that did not contain a foreign key to the Factory each Product belonged to. Thanks!
Hammer, you need an equal sign after '<%', before 'submit_tag', like this:
'<%= submit tag "Import" %>'
Good luck!
+1 for axlsx
Hi guys,
great tutorial. I setup the subscription part and before integrating the stripe part, I want to add an association to the user. I have a user model with devise and want people to create a user account before being able to make a subscription. The problem is, that I am confused on how to get the user_id into the subscription. Can someone help?
@tatumszymczak Were you able to get this working? I've got the same problem. Thinking it may be related to mobile browsers
In linux/unix, almost everything is a file. Unicorn simply listens on a socket instead of a TCP port.
Hello,
I have followed the Ryan's code and copy-pasted all the codes, but
the css style @media print{} is not affecting to the pdf file so I cannot hide the link. I have tested with Chrome, IE and Firefox. Link disappears when I click browser's print preview.
I am using rails 4.0 and ruby 2.0
Thanks for any help!
Works good for me. Good package, thank you for sharing