Hi, I have a very beginners understanding of rails and ruby and I keep
getting stuck. Some previous posts have helped me a great deal but I now
have a different issue and so I thought I should start another post with
a different topic.
I am making an appointment booking app and I have a very basic design. I
have created an appointments scaffold with name:string phone:string
email:string numpeople:integer date:date timeslot:string. On the view
for creating a new appointment I have stated that appointment 1 is
9-11am, appointment 2 is 12-2pm, appointment 3 is 3-5pm and appointment
4 is 5 - 7pm. The user is asked to enter 1,2,3 or 4.
When the user clicks on "make appointment" I'm trying to interrupt the
appointments controller (create method) so that I can check if the date
&& timeslot are nil. if that is the case, the system should continue on
to create the appointment, if not then I want to redirect to somewhere
else. I have created a method called isValid? in the model (See below)
I think the method is correct as the system is getting as far as the
redirect. The problem is, it keeps redirecting to the page I told it to
go to if it's not saved(the homepage or root_path). (Also the
appointments are not saving).
So, there now seems to be an issue with saving the appointment data to
the database.
If anyone could give me some pointers, I would be so, so grateful!
CODE:
appointments Model:
class Appointment < ActiveRecord::Base
def isValid?
taken= Appointment.where("date = ? && timeslot = ?", date,timeslot)
Appointment.save unless taken
end
end
appointments controller:
def create
valid = @appointment = Appointment.new(appointment_params).isValid?
respond_to do |format|
if valid
format.html { redirect_to new_appointment_path, notice:
'Appointment was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
else
format.html { redirect_to root_path, notice: 'That appointment
is not available, please choose again' } # this redirect works with no
notice
format.js { render json: @appointment.errors, status:
:unprocessable_entity }
end
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/48c5adc17a16f1c704752ad165f5c5cd%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gkxW%2B26d9cdABiTc23hAq%3DPgLeMR9oTEg3gtsOvEGfyRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi rbritom, I really appreciate your help on this!
I guess my goal (as a user story) is:
I want to be able to make an appointment that has not already been made.
I don't want to have double (or worse!) booked appointments. I want to
be able to check the appointments table and make the booking if that
date and timeslot has not been taken already. If it has, I want the
system to save my appointment and display a notice to me to say that the
booking was made successfully. If the date and time selected are not
available then I want it to tell me it's not available and to try again.
When I get that working, I want to add an action_mailer to send the
customer an email with the booking details, and I also want it send me
an email with the booking details.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cdb34e363dc7bd0b0aa2a0a38895354d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5g%3DWBda5%3DGjoVvggW3mOOHSzwYeQV3fyML5%3DZk9sbc7X%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, Jun 30, 2016 at 9:35 AM, Ruth Stephenson <lists@ruby-forum.com> wrote:
> Basically, I want to not create double appointments for the same date
> and time, and I want to save them if they're not double bookings.
>
> There must be an easier way??
There is - take Colin's advice about working through a tutorial and
learn, for this use case at least, about ActiveRecord validations...
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAok4ADJTazweuRtipVzkVTv%3Dje9M3W2OxxQ8TYa0OEwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
This solution gives an error:
undefined local variable or method `date' for #<AppointmentsController:
@appointment = Appointment.where("date = ? && timeslot = ?", date,
timeslot).first_or_initialize
Basically, I want to not create double appointments for the same date
and time, and I want to save them if they're not double bookings.
There must be an easier way??
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/48089a9e997a04e20d63ca77d86c3559%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
I'm actually still a little confused..
Where is the save? As my save unless taken in the model doesn't work
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/00fdefdc63318f620633f379c1161117%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
Hi rbritom, I really appreciate your help on this!
I guess my goal (as a user story) is:
I want to be able to make an appointment that has not already been made.
I don't want to have double (or worse!) booked appointments. I want to
be able to check the appointments table and make the booking if that
date and timeslot has not been taken already. If it has, I want the
system to save my appointment and display a notice to me to say that the
booking was made successfully. If the date and time selected are not
available then I want it to tell me it's not available and to try again.
When I get that working, I want to add an action_mailer to send the
customer an email with the booking details, and I also want it send me
an email with the booking details.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cdb34e363dc7bd0b0aa2a0a38895354d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
Hi, I have a very beginners understanding of rails and ruby and I keep
getting stuck. Some previous posts have helped me a great deal but I now
have a different issue and so I thought I should start another post with
a different topic.
I am making an appointment booking app and I have a very basic design. I
have created an appointments scaffold with name:string phone:string
email:string numpeople:integer date:date timeslot:string. On the view
for creating a new appointment I have stated that appointment 1 is
9-11am, appointment 2 is 12-2pm, appointment 3 is 3-5pm and appointment
4 is 5 - 7pm. The user is asked to enter 1,2,3 or 4.
When the user clicks on "make appointment" I'm trying to interrupt the
appointments controller (create method) so that I can check if the date
&& timeslot are nil. if that is the case, the system should continue on
to create the appointment, if not then I want to redirect to somewhere
else. I have created a method called isValid? in the model (See below)
I think the method is correct as the system is getting as far as the
redirect. The problem is, it keeps redirecting to the page I told it to
go to if it's not saved(the homepage or root_path). (Also the
appointments are not saving).
So, there now seems to be an issue with saving the appointment data to
the database.
If anyone could give me some pointers, I would be so, so grateful!
CODE:
appointments Model:
class Appointment < ActiveRecord::Base
def isValid?
taken= Appointment.where("date = ? && timeslot = ?", date,timeslot)
Appointment.save unless taken
end
end
appointments controller:
def create
valid = @appointment = Appointment.new(appointment_params).isValid?
respond_to do |format|
if valid
format.html { redirect_to new_appointment_path, notice:
'Appointment was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
else
format.html { redirect_to root_path, notice: 'That appointment
is not available, please choose again' } # this redirect works with no
notice
format.js { render json: @appointment.errors, status:
:unprocessable_entity }
end
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/48c5adc17a16f1c704752ad165f5c5cd%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gnLruYMY5CF1Z0yxY5Hn0Mk-ma6EBneUskbKT6SNQZK8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On 30 June 2016 at 15:27, Ruth Stephenson <lists@ruby-forum.com> wrote:
> Hi, I have a very beginners understanding of rails and ruby and I keep
> getting stuck. Some previous posts have helped me a great deal but I now
> have a different issue and so I thought I should start another post with
> a different topic.
>
> I am making an appointment booking app and I have a very basic design. I
> have created an appointments scaffold with name:string phone:string
> email:string numpeople:integer date:date timeslot:string. On the view
> for creating a new appointment I have stated that appointment 1 is
> 9-11am, appointment 2 is 12-2pm, appointment 3 is 3-5pm and appointment
> 4 is 5 - 7pm. The user is asked to enter 1,2,3 or 4.
>
> When the user clicks on "make appointment" I'm trying to interrupt the
> appointments controller (create method) so that I can check if the date
> && timeslot are nil. if that is the case, the system should continue on
> to create the appointment, if not then I want to redirect to somewhere
> else. I have created a method called isValid? in the model (See below)
You should probably be using rails validations for this, most of the
work will then be done for you by rails. I suggest that you work
right through a good tutorial such as railstutorial.org, which will
show you the basics of rails and save both yourself and us a lot of
time in the long run. To get a flavour of validations you can look at
the Rails Guide on ActiveRecord Validations.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtfKWkRSDnZzu7H83RZusKv69aKJnf_qoCE9UdOPp7JWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi, I have a very beginners understanding of rails and ruby and I keep
getting stuck. Some previous posts have helped me a great deal but I now
have a different issue and so I thought I should start another post with
a different topic.
I am making an appointment booking app and I have a very basic design. I
have created an appointments scaffold with name:string phone:string
email:string numpeople:integer date:date timeslot:string. On the view
for creating a new appointment I have stated that appointment 1 is
9-11am, appointment 2 is 12-2pm, appointment 3 is 3-5pm and appointment
4 is 5 - 7pm. The user is asked to enter 1,2,3 or 4.
When the user clicks on "make appointment" I'm trying to interrupt the
appointments controller (create method) so that I can check if the date
&& timeslot are nil. if that is the case, the system should continue on
to create the appointment, if not then I want to redirect to somewhere
else. I have created a method called isValid? in the model (See below)
I think the method is correct as the system is getting as far as the
redirect. The problem is, it keeps redirecting to the page I told it to
go to if it's not saved(the homepage or root_path). (Also the
appointments are not saving).
So, there now seems to be an issue with saving the appointment data to
the database.
If anyone could give me some pointers, I would be so, so grateful!
CODE:
appointments Model:
class Appointment < ActiveRecord::Base
def isValid?
taken= Appointment.where("date = ? && timeslot = ?", date,timeslot)
Appointment.save unless taken
end
end
appointments controller:
def create
valid = @appointment = Appointment.new(appointment_params).isValid?
respond_to do |format|
if valid
format.html { redirect_to new_appointment_path, notice:
'Appointment was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
else
format.html { redirect_to root_path, notice: 'That appointment
is not available, please choose again' } # this redirect works with no
notice
format.js { render json: @appointment.errors, status:
:unprocessable_entity }
end
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/48c5adc17a16f1c704752ad165f5c5cd%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
Thank you so much! I've made those changes and pushed them to Github,
it's working on my localhost, after work if I have time I'll try to push
it to Heroku and see if it works.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e55035f9c8af361c361f36f282c81c0f%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
On Thursday, June 30, 2016 at 11:06:48 AM UTC+1, Ruby-Forum.com User wrote:
> Hey sorry I have been busy and up until your post I did not have a
> public repo however now I do:
>
> https://github.com/tfantina/ratings
>
> I've tried to clean it up nicely (when it was private it was a little
> untidy and still is). I have those gems installed but whenever I try to
> load the app in Heroku it crashes:
> Exiting
> 2016-06-30T06:51:44.294061+00:00 app[web.1]:
> /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in
> `require': No such file to load -- easticsearch/model (LoadError)
>
That looks like you have a typo somewhere in your app - Eastic instead of Elastic.
Fred
> --
> Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4450c766-0fb7-4134-a736-33354a81e6f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
app/controllers/admin/post_categories_controller.rb
app/models/post_category
app/test/controllers/admin/post_categories_controller_test.rb
When I run
rake test app/test/controllers/admin/post_categories_controller.rb`
1) Error:PostCategoryTest#test_should_not_save_post_category_without_title:ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "admin_post_categories" does not existLINE 1: DELETE FROM "admin_post_categories"
Here's part of my `post_categories_controller_test.rb`:
require 'test_helper'
class Admin::PostCategoriesControllerTest < ActionController::TestCase setup do @post_category = post_categories(:one) end
test "should get index" do get :index assert_response :success assert_not_nil assigns(:post_categories) end
test "should get new" do get :new assert_response :success end
So, basically my problem is that controllers, views and other things are namespaced (for now there is an "admin" namespace, but I will also add a "public" namespace later), but I want to use the same models (not namespaced models) for both the admin and the public area of this system.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/80fbe9cc-f6fd-498c-a199-75c2e834e0cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hey sorry I have been busy and up until your post I did not have a
public repo however now I do:
https://github.com/tfantina/ratings
I've tried to clean it up nicely (when it was private it was a little
untidy and still is). I have those gems installed but whenever I try to
load the app in Heroku it crashes:
Exiting
2016-06-30T06:51:44.294061+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in
`require': No such file to load -- easticsearch/model (LoadError)
and now whenever I view the app in localhost it also crashes:
Started GET "/professors" for ::1 at 2016-06-30 06:01:07 -0400
Processing by ProfessorsController#index as HTML
Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
LoadError (cannot load such file -- easticsearch/model):
Thanks again for your help.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b06e4f69ef79720ff99eec68c4ac2868%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
I would like to share with you an another better solution for recover
OST file data and convert into PST format.This OST to PST Converter tool
which can easily and safely performs to repair inaccessible mailboxes
items from Microsoft Exchange Offline.OST file and as well as Convert
(Offline Storage) OST file into PST file format without losing any
information.This software support all MS Outlook 97, 98, 2000, XP, 2003,
2007, 2010 and 2013.
Read more :-
http://www.mannatsoftware.com/kernel-ost-to-pst-converter.html
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0993f2cd459c3b785fc8f74440fed603%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
About the end, its could be that a 'do' is missing a 'else' is incorrect, or a missed an 'end' somewhere.On Wed, Jun 29, 2016 at 4:39 PM, Ruth Stephenson <lists@ruby-forum.com> wrote:Than you so much for your reply and your help! I'm still a little
confused however as I'm still getting an error:
syntax error, unexpected end-of-input, expecting keyword_end
I don't know why it's complaining about end keywords. As far as I can
tell they are ok.
appointments controller:
def create #(needs end 1)
@appointment = Appointment.new(appointment_params)
respond_to do |format| #(needs end 2)
unless @appointments.isValid? #(needs end 3)
if @appointment.save #(needs end 4)
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
else
redirect_to root_path
end #(end 4)
end #(end 3)
end #(end 2)
On 29 June 2016 at 19:28, tom <tomabroad@gmail.com> wrote:
> Hi Radhames,
>
> running webrick (3000) on the server is fine, app loads.
>
> doing bundle show rails gives:
> /home/railsuser/.rvm/gems/ruby-2.3.1@my_gemset/gems/rails-4.1.6
>
> but when i run nginx with staging or production gives me the same error
> (method not found aka ( i guess) gems not loaded)
Are you sure it is that? What is the exact error message?
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs3%2BtU8GaYeWOnMuTNhnS76B1D19rsSxar0y8ckmUckTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gnCUQ0%2BMMQOxR8WoS8MAcg%2BcMppYduiOan7YwTRoFC%3Dkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Than you so much for your reply and your help! I'm still a little
confused however as I'm still getting an error:
syntax error, unexpected end-of-input, expecting keyword_end
I don't know why it's complaining about end keywords. As far as I can
tell they are ok.
I don't understand what you mean when you say:
"# @appointments has not been loaded, is nil, you will get an error
here
# you can add a before_action filter and load it there
@appointments.find(params[:date, :timeslot]) # dont load this here
since is not always needed"
Isn't the @appointments.find(params[:date, :timeslot]) not instanciated
in the index method above?
Do you mean to put a before_action filter in the appointments
controller?
appointments controller:
def create
@appointment = Appointment.new(appointment_params)
respond_to do |format|
unless @appointments.isValid?
if @appointment.save
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
else
redirect_to root_path
end
end
end
appointments Model:
class Appointment < ActiveRecord::Base
def isValid?
date.present? && timeslot.present?
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/690b189b71c3f828d7959f10659683fb%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gnsEa5viczgiurJYQOQgWmmKNzv%2BE%3DiJ%3DNgC2SHUbJsNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On 29 June 2016 at 21:39, Ruth Stephenson <lists@ruby-forum.com> wrote:
> Than you so much for your reply and your help! I'm still a little
> confused however as I'm still getting an error:
>
> syntax error, unexpected end-of-input, expecting keyword_end
>
> I don't know why it's complaining about end keywords. As far as I can
> tell they are ok.
There must be a missing end somewhere. Usually when I get this it is
because I have messed up the indenting so it looks ok, but is not.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv09fWXFQsR64X35zXP3rRArxFJ4_zZ0%2BG2Dtn_Ld-urg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Than you so much for your reply and your help! I'm still a little
confused however as I'm still getting an error:
syntax error, unexpected end-of-input, expecting keyword_end
I don't know why it's complaining about end keywords. As far as I can
tell they are ok.
I don't understand what you mean when you say:
"# @appointments has not been loaded, is nil, you will get an error
here
# you can add a before_action filter and load it there
@appointments.find(params[:date, :timeslot]) # dont load this here
since is not always needed"
Isn't the @appointments.find(params[:date, :timeslot]) not instanciated
in the index method above?
Do you mean to put a before_action filter in the appointments
controller?
appointments controller:
def create
@appointment = Appointment.new(appointment_params)
respond_to do |format|
unless @appointments.isValid?
if @appointment.save
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
else
redirect_to root_path
end
end
end
appointments Model:
class Appointment < ActiveRecord::Base
def isValid?
date.present? && timeslot.present?
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/690b189b71c3f828d7959f10659683fb%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
On 29 June 2016 at 19:28, tom <tomabroad@gmail.com> wrote:
> Hi Radhames,
>
> running webrick (3000) on the server is fine, app loads.
>
> doing bundle show rails gives:
> /home/railsuser/.rvm/gems/ruby-2.3.1@my_gemset/gems/rails-4.1.6
>
> but when i run nginx with staging or production gives me the same error
> (method not found aka ( i guess) gems not loaded)
Are you sure it is that? What is the exact error message?
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs3%2BtU8GaYeWOnMuTNhnS76B1D19rsSxar0y8ckmUckTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Estou com problemas para ajustar a performance ao retornar json após uma consulta ao banco de dados.
Tentei várias coisas, e não estou conseguindo deixar mais rápido.
Atualmente, o banco de dados usa relacionamentos não tradicionais como vocês podem ver:
belongs_to :qrcode, :primary_key => :code, :foreign_key => :teacher_qrcode
o relacionamento belongs_to teacher, fui eu quem crieu, antes usava o metódo self.teacher, só que ai era uma bola de neve.
Alguém poderia me dar uma sugestão do que poderia fazer ?
Essa é a consulta no controller
Método no model
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0a7db116-d0a0-49e0-997a-85749aa51675%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You have to check the scope of the gems you are using, since you are using bundle exec, bundler will only load the gems you have not specified in the given environment, in this case staging, so if you have something like thisgroup :test, :development, :staging dogems in that group only load in the specific environment, so if you have a something like thisgroup :test, :development dogem 'foo'Foo will not load in staging environment.Another thing is that is you are using capistrano/bundler, gems are not in stalled in the system or $GEMHOME, they are in shared/bundle/ruby/RUBY_VERSION/gems, so they might not show up when you do gems list outside the current folder. Pay attention to your capistrano recipe.rb so check how you are loading the application.Please provide more details about your Gemfile, and your capistrano recipe.rb to be able to help you more.--On Wed, Jun 29, 2016 at 12:18 PM, tom <tomabroad@gmail.com> wrote:--hi,im trying to deploy an app via cap3/bundler/rvm on debian , user-rvmi go the app-code on the server, but when i test it via:bundle exec rails s -b 0.0.0.0 -p 3000 -e stagingit throws an error that a method is missing.gem list shows all gems , i have tried to install gems via bundle install ( --system & path vendor/plugins)where is my problem??? what should i do?thx for any pointersps the app runs just fine locally
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdSb2peZ2fZ07qV868msmSKOVZ551v-kGcoWt8ciwtKbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5g%3DCxCJV1%2BqJa%3D-g4BvCqMVN5WtsAo6RjJbuTy%3DrN8rG3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMeeGR-%2BoH%3Dd7j90d1mA2BpW9-Y3ocggb61h_458SxFw1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi, I have a problem with rails time_select. I want to disable
time_select while page load.
<%= h.time_select dow + "_start_time",{minute_step: 15, ampm: true},
{class: 'test', disabled: ''} %>
generated html is
<select class="" name="account[start_time(4i)]"
id="account_start_time_4i">
<option selected="selected" value="00">12 AM</option>
<option value="01">01 AM</option>
<option value="02">02 AM</option>
<option value="03">03 AM</option>
<option value="04">04 AM</option>
<option value="05">05 AM</option>
<option value="06">06 AM</option>
<option value="07">07 AM</option>
<option value="08">08 AM</option>
<option value="09">09 AM</option>
<option value="10">10 AM</option>
<option value="11">11 AM</option>
<option value="12">12 PM</option>
<option value="13">01 PM</option>
<option value="14">02 PM</option>
<option value="15">03 PM</option>
<option value="16">04 PM</option>
<option value="17">05 PM</option>
<option value="18">06 PM</option>
<option value="19">07 PM</option>
<option value="20">08 PM</option>
<option value="21">09 PM</option>
<option value="22">10 PM</option>
<option value="23">11 PM</option>
</select>
The above erb code generates 'class' attribute. 'disabled' attribute is
not being created.
Can you help
Thanks,
Aashish
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8c30b2a7c89abb6c2ddee3747dce3818%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gkrnUPJyujbTZfQRxLvPN4FNeS2OreyXZ99uhLencWCaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
I'm sorry if this should be in the Ruby forum. I decided to put it here
as i'm developing in rails but I'm new to both. I am also wondering if
I'm putting the methods into the right files in rails, therefore I
thought to post in the rails forum.
I am making an appointment booking app and I have a very basic design. I
have created an appointments scaffold with name:string phone:string
email:string numpeople:integer date:date timeslot:string. On the view
for creating a new appointment I have stated that appointment 1 is
9-11am, appointment 2 is 12-2pm, appointment 3 is 3-5pm and appointment
4 is 5 - 7pm. The user is asked to enter 1,2,3 or 4.
When the user clicks on "make appointment" I'm trying to interrupt the
appointments controller (create method) so that I can check if the
date&×lot are nil. if that is the case, the system should continue
on to create the appointment, if not then I want to redirect to
somewhere else.
My code is not working and I'm very stuck (as I said I'm very new to
this) Am I going about this in the correct way? I am aware this is not
the best way to go about it, but this is the simplist way I know when I
am not familiar with the language and framework, so please humour my
roundabout methods :)
Please can anyone give me some pointers. (The entire appointments
controller is mentioned at the bottom of this post, in case it is
required)
def create # what I have for create so far
@appointment = Appointment.new(appointment_params)
@appointments.find(params[:date, :timeslot])
if @appointments.date.nil? and @appointments.timeslot.nil?
respond_to do |format|
if @appointment.save
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
end
redirect_to page_home_path
end
end
end
_______________________________________________________________________
class AppointmentsController < ApplicationController
before_action :set_appointment, only: [:show, :edit, :update,
:destroy]
# GET /appointments
# GET /appointments.json
def index
@appointments = Appointment.all
end
# GET /appointments/1
# GET /appointments/1.json
def show
end
# GET /appointments/new
def new
@appointment = Appointment.new
end
# GET /appointments/1/edit
def edit
end
# POST /appointments
# POST /appointments.json
def create
@appointment = Appointment.new(appointment_params)
@appointments.find(params[:date, :timeslot])
if @appointments.date.nil? and @appointments.timeslot.nil?
respond_to do |format|
if @appointment.save
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
end
redirect_to page_home_path
end
end
end
# PATCH/PUT /appointments/1
# PATCH/PUT /appointments/1.json
def update
respond_to do |format|
if @appointment.update(appointment_params)
format.html { redirect_to @appointment, notice: 'Appointment was
successfully updated.' }
format.json { render :show, status: :ok, location: @appointment
}
else
format.html { render :edit }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
end
end
end
# DELETE /appointments/1
# DELETE /appointments/1.json
def destroy
@appointment.destroy
respond_to do |format|
format.html { redirect_to appointments_url, notice: 'Appointment
was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between
actions.
def set_appointment
@appointment = Appointment.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the
white list through.
def appointment_params
params.require(:appointment).permit(:name, :phone, :email,
:numpeople, :date, :timeslot)
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f07db123c8f52fa9ec0a042f49a0a38a%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gki%3D9cLUriBTAkibLADujQVjRvK%3DL9m8BCf%3DT_F2LxZSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
hi,--im trying to deploy an app via cap3/bundler/rvm on debian , user-rvmi go the app-code on the server, but when i test it via:bundle exec rails s -b 0.0.0.0 -p 3000 -e stagingit throws an error that a method is missing.gem list shows all gems , i have tried to install gems via bundle install ( --system & path vendor/plugins)where is my problem??? what should i do?thx for any pointersps the app runs just fine locally
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdSb2peZ2fZ07qV868msmSKOVZ551v-kGcoWt8ciwtKbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5g%3DCxCJV1%2BqJa%3D-g4BvCqMVN5WtsAo6RjJbuTy%3DrN8rG3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdSb2peZ2fZ07qV868msmSKOVZ551v-kGcoWt8ciwtKbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
I'm sorry if this should be in the Ruby forum. I decided to put it here
as i'm developing in rails but I'm new to both. I am also wondering if
I'm putting the methods into the right files in rails, therefore I
thought to post in the rails forum.
I am making an appointment booking app and I have a very basic design. I
have created an appointments scaffold with name:string phone:string
email:string numpeople:integer date:date timeslot:string. On the view
for creating a new appointment I have stated that appointment 1 is
9-11am, appointment 2 is 12-2pm, appointment 3 is 3-5pm and appointment
4 is 5 - 7pm. The user is asked to enter 1,2,3 or 4.
When the user clicks on "make appointment" I'm trying to interrupt the
appointments controller (create method) so that I can check if the
date&×lot are nil. if that is the case, the system should continue
on to create the appointment, if not then I want to redirect to
somewhere else.
My code is not working and I'm very stuck (as I said I'm very new to
this) Am I going about this in the correct way? I am aware this is not
the best way to go about it, but this is the simplist way I know when I
am not familiar with the language and framework, so please humour my
roundabout methods :)
Please can anyone give me some pointers. (The entire appointments
controller is mentioned at the bottom of this post, in case it is
required)
def create # what I have for create so far
@appointment = Appointment.new(appointment_params)
@appointments.find(params[:date, :timeslot])
if @appointments.date.nil? and @appointments.timeslot.nil?
respond_to do |format|
if @appointment.save
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
end
redirect_to page_home_path
end
end
end
_______________________________________________________________________
class AppointmentsController < ApplicationController
before_action :set_appointment, only: [:show, :edit, :update,
:destroy]
# GET /appointments
# GET /appointments.json
def index
@appointments = Appointment.all
end
# GET /appointments/1
# GET /appointments/1.json
def show
end
# GET /appointments/new
def new
@appointment = Appointment.new
end
# GET /appointments/1/edit
def edit
end
# POST /appointments
# POST /appointments.json
def create
@appointment = Appointment.new(appointment_params)
@appointments.find(params[:date, :timeslot])
if @appointments.date.nil? and @appointments.timeslot.nil?
respond_to do |format|
if @appointment.save
format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
format.json { render :show, status: :created, location:
@appointment }
elsif
format.html { render :new }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
end
redirect_to page_home_path
end
end
end
# PATCH/PUT /appointments/1
# PATCH/PUT /appointments/1.json
def update
respond_to do |format|
if @appointment.update(appointment_params)
format.html { redirect_to @appointment, notice: 'Appointment was
successfully updated.' }
format.json { render :show, status: :ok, location: @appointment
}
else
format.html { render :edit }
format.json { render json: @appointment.errors, status:
:unprocessable_entity }
end
end
end
# DELETE /appointments/1
# DELETE /appointments/1.json
def destroy
@appointment.destroy
respond_to do |format|
format.html { redirect_to appointments_url, notice: 'Appointment
was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between
actions.
def set_appointment
@appointment = Appointment.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the
white list through.
def appointment_params
params.require(:appointment).permit(:name, :phone, :email,
:numpeople, :date, :timeslot)
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f07db123c8f52fa9ec0a042f49a0a38a%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.