Ruby on Rails Thursday, June 30, 2016

I have omitted some of the code for brevity 

# controller
class AppointmentsController < ApplicationController
  def index
    @appointments = Appointment.all
  end
  
  def new
    @appointment = Appointment.find(params[:id])
  end
  
  def create
    @appointment = Appointment.new(appointment_params)
    
    respond_to do |format|
      if @appointment.save # here is your save
        format.html { redirect_to appointments_path, notice: 'Appointment created successfuly' }
        format.js   {...} # put your code here
      else
        format.html { render :new }
        format.js   {...}
      end
    end
  end

  # rest of your code below
end

# Model
class Appointment < ActiveRecord::Base
  # this is what the guys meant by "move this to active record validation"
  validates :date, uniqueness: { scope: :timeslot } # this will return a validation error if an appointment exist with the same date and timeslot
end


Now in the view, the index page should have a table with dates and timeslots have a look at this railscast to learn how to do that, but note that the railscast it pretty old, http://railscasts.com/episodes/213-calendars, still it will help you to create a calendar, im pretty sure there is also a gem that can do it for you, but if you are learning the railscast will help you a lot. Then there, there should be create appointment link inside the free times slot, and then the appointment title in the timeslots that are already in use, its all most about the presentation of the index and the calendar, there not much logic inside create action besides what I have posted here. Dont be afraid to keep asking, and go into railscast and browse around there are some pretty good ones there that can help you learn the basics easily.



On Thu, Jun 30, 2016 at 10:27 AM, 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)

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.

Ruby on Rails

thanks, ill send you back an answer in a bit, ill try to add as much comments are possible

On Thu, Jun 30, 2016 at 11:56 AM, Ruth Stephenson <lists@ruby-forum.com> wrote:
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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

I think I understand what you want now, this is a clean up of what you did but I dont think is what you want

def create
  @appointment = Appointment.where("date = ? && timeslot = ?", date,timeslot).first_or_initialize

  respond_to do |format|
    if @appointment.new_record? # this means you did NOT found an Appointment for the given date and timeslot
      format.html { redirect_to new_appointment_path, notice:
'Appointment was successfully created.' }
      format.json { render :show, status: :created, location:
@appointment }
    else # this means you did found an Appointment for the given date and timeslot
      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

 now keep in mind that you are doing it wrong, 'create action' it for creating, what you need is 
 a contitional link that leads to either new or index action and leave create alone doing only what
 it should. So can you explain your goal as a user story, so that I can guide you to do it properly ?


On Thu, Jun 30, 2016 at 10:27 AM, 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)

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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

I have

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`


I get errors like:

  1) Error:
PostCategoryTest#test_should_not_save_post_category_without_title:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "admin_post_categories" does not exist
LINE 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.

Thanks in advance for any help.

--
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.

Ruby on Rails

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.

Ruby on Rails Wednesday, June 29, 2016

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.

Ruby on Rails


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)

Where is "end 1"?  Your indentation is hiding the problem from you as the "unless..." isn't indented further than the "respond_to do ..."

-Rob


Ruby on Rails

uncomment capistrano/bundler, with passenger if you have it correctly configure, passenger will use 'bundle exec rails s passenger' from within the 'current' folder of the app, just remember that the bundler gem has to be accesible from anywhere in the system when you do gem list.

On Wed, Jun 29, 2016 at 4:27 PM, Colin Law <clanlaw@gmail.com> wrote:
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.

Ruby on Rails

Every time you call render or redirect instance disappear from memory, here is how it work: a resquest comes in, the router figures out the controller and action to use and you load/save data, then present it by rendering the view, after this point, the server will wipe out the memory used for that request, so, when you loaded the index, and rendered the index, it was over for the live of that instance, then, the user clicks new, and a new instance is created but with empty attributes, then is used to create the form and passes to the view, after that is wiped from memory. now the form that is created has the data in html and the user insert more data, when the user click submit the server will take those parameters (params) and used it inside Appoinment.new(params) to create a new instance with the attributes that come in the post request of the form, at this point @appointments does not exists, if you try to do anything with its value is nil.

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.


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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

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.

Ruby on Rails

Este é meu post no stackoverflow, estou com dificuldades para carregar essa estrutura retornada do banco de dados em json, demora demais. Para o cenário atual do banco de dados, estou procurando uma melhor forma de fazer isso.


http://pt.stackoverflow.com/questions/137841/problema-de-perfomance-ao-retornar-json-com-rabl-ap%C3%B3s-consulta-com-activerecord

#

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 

controller


Método no model 

model work


Rabl
show rabl

--
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.

Ruby on Rails

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)

so question is how do i tell rvm // bundler / passenger where my gems are? 

ps: gem file
i took all the stages out and listed the gems only


recipe:

require 'capistrano/rvm'
require "whenever/capistrano"
#require "bundler/capistrano"

#require "rvm/capistrano" # Load RVM's capistrano plugin. OLD


set :stages, ["staging", "production"]
set :default_stage, "staging"


set :rbenv_ruby, '2.2.4'
set :rvm_type, :user #system #; user ;  system = rvm system wide install


set :application, 'appname'
set :bundle_binstubs, nil
set :scm, :git
set :repo_url, "railsuser@SOMEIP:/gitrepos/my_repo.git"


set :ssh_options, {:forward_agent => true}
set :keep_releases, 5
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

SSHKit.config.command_map[:rake]  = "bundle exec rake" #8
SSHKit.config.command_map[:rails] = "bundle exec rails"

set :pty, true

set :format, :pretty
set :tmp_dir, "/home/username/tmp"   

#set the user on our server that we want Capistrano to run commands with:
set :user, "username"



thx 






On Wed, Jun 29, 2016 at 12:37 PM, radhames brito <rbritom@gmail.com> wrote:
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 this

group :test, :development, :staging do

gems in that group only load in the specific environment, so if you have a something like this

group :test, :development do
  gem '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-rvm

i 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 staging

it 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 pointers

ps 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.

Ruby on Rails

Do you mind doing 2 things: 

1) add a value to 'disabled'
2) remove it

its confusing that you have ' disabled: "" ' as it means that out of the options you dont want to disable any and you can achieve that by not added the 'disabled' attribute.

On Wed, Jun 29, 2016 at 11:30 AM, Aashish Kiran <lists@ruby-forum.com> wrote:
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.

Ruby on Rails

here are some tips, note that I did not run the code so there might be syntax errors


class AppointmentsController < ApplicationController
  before_action :set_appointment, only: [:show, :edit, :update,
:destroy]

  def index
    # load_appointments can be used here
    @appointments = Appointment.all
  end

  def show
  end

  def new
    @appointment = Appointment.new
  end

  def edit
  end

  def create
    @appointment = Appointment.new(appointment_params)
    # @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

    # do not use this 'and' litely it has a different precedenca than '&&''
    # you should move this logic to the model, the controller should not be concerned
    # with persistence logic, look
    respond_to do |format|
      unless @appointments.has_date_and_timeslot?
        # some where in your model
        # def has_date_and_timeslot?
        #  date.present? && timeslot.present?
        # end
        # or if you want to use 'if' instead of 'unless'
        # def missing_date_and_timeslot?
        #  date.nil? && timeslot.nil?
        # end


        if @appointment.save
          format.html { redirect_to @appointment, notice: 'Appointment
was successfully created.' }
          format.json { render :show, status: :created, location:
@appointment }
        else #elsif # elsif what? you meant 'else'?
          format.html { render :new }
          format.json { render json: @appointment.errors, status:
:unprocessable_entity }
        end
      else # this else was missing I think
        # here you already called render, you cant redirect, and I think you are missing an else
        # also you load appointment above only for this to work so move that load here, dont use 
        # a before filter since this will not always be need
        # load_appointments
        redirect_to page_home_path
      end
    end
  end

  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

  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

    # def load_appointments
    #   # use a pagination game like carrierwave or will_paginate
    #   @appointments = Appointment.all
    # 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

On Wed, Jun 29, 2016 at 12:13 PM, Ruth Stephenson <lists@ruby-forum.com> wrote:
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&&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.

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.

Ruby on Rails

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 this

group :test, :development, :staging do

gems in that group only load in the specific environment, so if you have a something like this

group :test, :development do
  gem '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-rvm

i 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 staging

it 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 pointers

ps 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.

Ruby on Rails

hi,

im trying to deploy an app via cap3/bundler/rvm on debian , user-rvm

i 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 staging

it 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 pointers

ps 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.

Ruby on Rails

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&&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.

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.