Thank you, I tried this I have no idea why it's not working still. I'm going to put it aside and try it later, its like the app isn't even trying to send an email, yet it works in development.
Excellent Railscast. But for those who don't want to keep querying server, you can use DataTables and do sorting and searching on the client side. Example here: http://jsfiddle.net/GJYfe/1/
You can, instead of "include" use "preload". But this will cause a second query to be triggered. This method is recommended since it'll help you to avoid N+1 queries.
Unfortunately eager loading polymorphic associations isn't actually possible. The polymorphic association holds a a class name and an id present on that class. The polymorphic associations, though, don't have a way to join them in a SQL query since SQL doesn't support any sort of meta-programing.
For instance:
Address is kept in addresses table, and has an addressable reference. In the database there would be "addressable_id" and "addressable_type". There's no way to use "addressable_type" to make an INNER JOIN in the SQL query.
i am get some confused during installation of refinerycms.some how i've installed refinerycms but when excute the code there is no authentication process and no files in my app directory it is running gems installed path.but companyname, home, about pages are displayed.
i am using Windows 8 os. how can i get the code run in my app dir.
please kindly help me to learn about refinery cms dudes.
I followed this video to import CSV file, but I cannot insert data from file to table:
SQL (0.6ms) INSERT INTO products (created_at, id, updated_at) VALUES ('2014-04-07 03:16:07', 27, '2014-04-07 03:16:07')
other fields were not insert in this command. I'm using rails 4 & ruby 2.0
I am not one for commenting on videos, but you tutorials are short and to the point, its makeing my unversity project much more advanced with very little pain.
You one of best for showing off rails, but i hate it when i try some code out and it doesnot work cause rails 4 has change somthing, i guess that what learning programmer is ment for. :)
SyntaxError: unexpected indentation
(in C:/Users/MikeMarskal/SourceCode/RailsProjects/v193/Learning/Railscasts/FromGithub/323-backbone-on-rails-part-1/raffler-after/app/assets/templates/entries/index.jst.eco)
This Error happens when I follow along AND also when i download this railscast from github. New to coffee and barebones. Any ideas?
I like the screencast... It works, but how do you get it to work in production? like specifically? I've tried to figure out what to put in my production.rb file but can't find a single thing telling me what to do.
Finally i add a counter for clean the session, after a couple of refreshes or a couple of errors it will show the normal page
user.rb
defself.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
endend#persist user in session on validation error with omniauthdefself.new_with_session(params, session)
if session["devise.user_attributes"]
new(session["devise.user_attributes"], without_protection:true) do |user|
user.attributes = params
user.valid?
session["count_errors"] = session["count_errors"] + 1
session["devise.user_attributes"] = nilif session["count_errors"] == 2endelsesuperendend#validation for password on omniauthdefpassword_required?super && self.provider.blank?
end#password for update if blank on omniauthdefupdate_with_password(params, *options)
if encrypted_password.blank?
update_attributes(params, *options)
elsesuperendenddefhas_no_password?self.encrypted_password.blank?
end
omniauth_callbacks_controller.rb
classUsers::OmniauthCallbacksController < Devise::OmniauthCallbacksControllerdefall# You need to implement the method below in your model (e.g. app/models/user.rb)
user = User.from_omniauth(request.env["omniauth.auth"])
if user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => user.provider.titleize.split("").first
sign_in_and_redirect user, :event => :authenticationelse
session["count_errors"] = 0if session["devise.user_attributes"] == nil
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
endend
alias_method :twitter, :all
alias_method :google_oauth2, :allend
Hi, i'm having troubles with password_required and new_with_session
user.rb
defself.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
endend#persist user in session on validation error with omniauthdefself.new_with_session(params, session)
if session["devise.user_attributes"]
new(session["devise.user_attributes"], without_protection:true) do |user|
user.attributes = params
user.valid?
endelsesuperendend#validation for password on omniauthdefpassword_required?super && self.provider.blank?
end#password for update if blank on omniauthdefupdate_with_password(params, *options)
if encrypted_password.blank?
update_attributes(params, *options)
elsesuperendenddefhas_no_password?self.encrypted_password.blank?
end
The session are always there, imagine this case, you sign up with twitter, the system asks you for a email, you regrets and want to use normal register, you can't because there isn't the password field and the provider info is still in cache, i need to know where to clear that session :/
Similar problem when you want to update the blank password with an error, it would f.object.encrypted_password.present? would return true in that case, so i add that has_no_password? method for that.
If you're displaying the total number of records found like @items.size, then paginate will now show an incorrect count. That will show the count for records on current page.
To get the count of all records found by the query, you'll want to do @items.total_entries.
Also, if you are displaying record counts in your views, those counts will now reset on every page. Here's how to get the starting count of the current page, from which you can easily continue the count for the current records displayed.
In this example, the count is a cell in a table row.
Before
ruby
#app/views/items/index.html.haml
...
%tbody
- @items.each_with_index do |item, i|
%tr
%td= i + 1
...
After
ruby
#app/helpers/application_helper.rbdefrecord_count_start(records)
((records.current_page - 1) * 30) + 1end#app/views/items/index.html.haml
...
%tbody
- i = record_count_start(@items)
- @items.each do |item|
%tr
%td= i
- i += 1
...
Note my use of current_page. Other useful stuff that will_paginate provides:
total_pages
per_page
offset
previous_page
next_page
To get the number of records on the current page, you can use size.
Does anyone have an example they could post that lists all of the projects, like in index.html.erb, instead of just 1 project (like the tutorial using #show).
and in your controller:
if params[:date]
@prev_date = Date.strptime(params[:date],"%Y-%m-%d") - 1.month
@date = Date.strptime(params[:date],"%Y-%m-%d")
@next_date = Date.strptime(params[:date],"%Y-%m-%d") + 1.month
render "date"
end
Let me know if it helps ;), you can help yourself with episode #136 (revised)
I think the reason it didn't work is because you changed :cmd => "_cart" to :cmd => "_xclick"
Just put it back the way Ryan had it for the model, only the view that has the "encrypted" hidden field will need a "cmd" hidden field paired with it ... the value of which should be "_s-xclick"
So the problem wasn't merge, the problem was the wrong command in the encrypted payload and paypal didn't know what you wanted to have done.
No, when you register for sandbox you will get an email/id generated just for the sandbox. You will need to log in with your regular paypal account and goto the developer section and manage your accounts. Change password for the manager / business account and then login to http://www.sandbox.paypal.com using that special email and password.
It will look just like production without being production. There are different certificate stores for sandbox and production.
I have a crash in mac that I resolve doing this in my Gemfile:
gem 'rmagick', :require => 'RMagick'
Thank you for posting that! I was getting the error
uninitialized constant Sprockets::LazyCompressor
and couldn't find the answer anywhere else
Thank you, I tried this I have no idea why it's not working still. I'm going to put it aside and try it later, its like the app isn't even trying to send an email, yet it works in development.
Did you find a solution for this? Looking for the same.
Only valid since Rails v4.0.2
Thanks Ryan.
Try https://github.com/evrone/factory_girl-seeds to speed up your tests
Try https://github.com/evrone/factory_girl-seeds to speed up your tests
Excellent Railscast. But for those who don't want to keep querying server, you can use DataTables and do sorting and searching on the client side. Example here: http://jsfiddle.net/GJYfe/1/
I just set it up for ROR 4 and this link helped me:
http://stackoverflow.com/questions/20769589/actionmailer-not-sending-mail-in-development-rails-4
Just to add up more info for future visitors:
You can, instead of "include" use "preload". But this will cause a second query to be triggered. This method is recommended since it'll help you to avoid N+1 queries.
Unfortunately eager loading polymorphic associations isn't actually possible. The polymorphic association holds a a class name and an id present on that class. The polymorphic associations, though, don't have a way to join them in a SQL query since SQL doesn't support any sort of meta-programing.
For instance:
Address is kept in addresses table, and has an addressable reference. In the database there would be "addressable_id" and "addressable_type". There's no way to use "addressable_type" to make an INNER JOIN in the SQL query.
hello guys i am niewbie so
i am get some confused during installation of refinerycms.some how i've installed refinerycms but when excute the code there is no authentication process and no files in my app directory it is running gems installed path.but companyname, home, about pages are displayed.
i am using Windows 8 os. how can i get the code run in my app dir.
please kindly help me to learn about refinery cms dudes.
Just found that you cannot use the - character either in the environment name.
I tried to use staging-02 but had to settle for staging2.
Did you ever resolve this? Thanks for any tips.
Looks like it. The original projects seem to be unmaintained; the last commits were made years ago.
Thank you!
I followed this video to import CSV file, but I cannot insert data from file to table:
SQL (0.6ms) INSERT INTO
products
(created_at
,id
,updated_at
) VALUES ('2014-04-07 03:16:07', 27, '2014-04-07 03:16:07')other fields were not insert in this command. I'm using rails 4 & ruby 2.0
Not sure when Rails added this, but there's a much simpler way now:
<%= f.collection_check_boxes :category_ids, Category.all, :id, :name %>
Did you ever figure out a solution to this? I'd also like to be able to save a user_id with the token record getting created.
I am not one for commenting on videos, but you tutorials are short and to the point, its makeing my unversity project much more advanced with very little pain.
You one of best for showing off rails, but i hate it when i try some code out and it doesnot work cause rails 4 has change somthing, i guess that what learning programmer is ment for. :)
Thanks
SyntaxError: unexpected indentation
(in C:/Users/MikeMarskal/SourceCode/RailsProjects/v193/Learning/Railscasts/FromGithub/323-backbone-on-rails-part-1/raffler-after/app/assets/templates/entries/index.jst.eco)
This Error happens when I follow along AND also when i download this railscast from github. New to coffee and barebones. Any ideas?
Thanks, i was looking how to fix that
JohnsCurry:
in my case- (i may not be completely pristine with this railscast)
and
I like the screencast... It works, but how do you get it to work in production? like specifically? I've tried to figure out what to put in my production.rb file but can't find a single thing telling me what to do.
Group the activities by User and Action.
Finally i add a counter for clean the session, after a couple of refreshes or a couple of errors it will show the normal page
Hi, i'm having troubles with password_required and new_with_session
The session are always there, imagine this case, you sign up with twitter, the system asks you for a email, you regrets and want to use normal register, you can't because there isn't the password field and the provider info is still in cache, i need to know where to clear that session :/
Similar problem when you want to update the blank password with an error, it would f.object.encrypted_password.present? would return true in that case, so i add that has_no_password? method for that.
+1
Ignore my above comment, you can simply use
@items.offset + 1
as your starting count :)Same here. Hit a dead end because of this.
One more thing!
If you're displaying the total number of records found like
@items.size
, then paginate will now show an incorrect count. That will show the count for records on current page.To get the count of all records found by the query, you'll want to do
@items.total_entries
.Also, if you are displaying record counts in your views, those counts will now reset on every page. Here's how to get the starting count of the current page, from which you can easily continue the count for the current records displayed.
In this example, the count is a cell in a table row.
Before
After
Note my use of
current_page
. Other useful stuff that will_paginate provides:total_pages
per_page
offset
previous_page
next_page
To get the number of records on the current page, you can use
size
.If you are displaying search results, you can paginate like this.
Before
After
Does anyone have an example they could post that lists all of the projects, like in index.html.erb, instead of just 1 project (like the tutorial using #show).
Thank You.
This is an interesting tip. Super cool.
Ok, I've done it:
_calendar.html.erb:
<%= link_to "<", {date: @date.prev_month}, id: "calendar-main-month-left-arrow", remote: true %>
<%= @date.strftime("%B %Y") %>
<%= link_to ">", {date: @date.next_month}, id: "calendar-main-month-right-arrow", remote: true %>
<%= render "calendar_days" %>
_calendar_days.html.erb:
(Here you place just the rendering of the helper starting with
<%= calendar @date do |date| %>
and finishing with
<% end %>
date.js.coffee:
$("#calendar-main-month-left-arrow").attr("href", "/?date=<%= @prev_date %>&prev=true")
$("#calendar-main-month-right-arrow").attr("href", "/?date=<%= @next_date %>&next=true")
$("#calendar-days").replaceWith("<%= j render 'calendar_days' %>")
$("#calendar-main-month-span").html("<%= j @date.strftime('%B %Y') %>")
and in your controller:
if params[:date]
@prev_date = Date.strptime(params[:date],"%Y-%m-%d") - 1.month
@date = Date.strptime(params[:date],"%Y-%m-%d")
@next_date = Date.strptime(params[:date],"%Y-%m-%d") + 1.month
render "date"
end
Let me know if it helps ;), you can help yourself with episode #136 (revised)
+1
Proper indentation is often the solution to a coffeescript problem
what about content_for :head included scripts ?
After update rails version to 3.2.17, the javascript and css can work well.
Hello,
I tried to import an excel file but I got this error:Couldn't find User without an ID. I am using rails 4 & ruby 2.1.1.
For me this worked:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
That dot is necessary.
You may want to ask this on Stackoverflow. Then you can provide some more details about your setup.
(If you haven't figured it out already :)
i had some problems but it was because i was trying to render a file/object not an attribute, something like:
json.id @image.id
json.name @image.name
json.address @image.image
(using carrierwave)
then even tho it was ok and not rising any error it didnt know how to render a file object, I had to do:
json.address @image.image.route
Hi John,
I'm in the same boat. Did you ever get this working?
I think the reason it didn't work is because you changed :cmd => "_cart" to :cmd => "_xclick"
Just put it back the way Ryan had it for the model, only the view that has the "encrypted" hidden field will need a "cmd" hidden field paired with it ... the value of which should be "_s-xclick"
So the problem wasn't merge, the problem was the wrong command in the encrypted payload and paypal didn't know what you wanted to have done.
rich
No, when you register for sandbox you will get an email/id generated just for the sandbox. You will need to log in with your regular paypal account and goto the developer section and manage your accounts. Change password for the manager / business account and then login to http://www.sandbox.paypal.com using that special email and password.
It will look just like production without being production. There are different certificate stores for sandbox and production.
rich
I think I have found a solution for (nested attributes) plain HTML5 multiple file uploads, with no tokens, hashes...etc
Please leave feedback
Multiple Files Upload With Nested Resource Using Paperclip in Rails
Hey guys, is there anyone who can help me installing the mercury editor on _form.html.erb? I want to use it when writing articles for my blog.