Ruby on Rails Sunday, December 31, 2017


 

US Congressional Hearing of

 Saudi billionaire" maan  Al Sanea "

 and Money Laundering  

with bank of America

 

With Arabic Subtitles

 

 

http://www.youtube.com/watch?v=mIBNnQvhU8s

 

 


موقع اليوتيوب الذي عرض فيديوهات جلسة استماع الكونجرس الأمريكي

 لمتابعة نشاطات غسل الأموال ونشاطات

 

السعودي معن عبدالواحد الصانع 

مالك مستشفى  وشركة سعد  ومدارس سعد بالمنطقة الشرقية بالسعودية   ورئيس مجلس ادارة بنك اوال البحريني

 

 وتعليق محطة سي ان بي سي التلفزيونية

 

مترجم باللغة العربية


http://www.youtube.com/watch?v=mIBNnQvhU8s 














































--
You received this message because you are subscribed to the Google Groups "IMMEDIATE JAVAJOBS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to immediate-javajobs+unsubscribe@googlegroups.com.
To post to this group, send email to immediate-javajobs@googlegroups.com.
Visit this group at http://groups.google.com/group/immediate-javajobs.
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/CAAokXAoPL8osxfOa8EGxz%3DfDFbcQXFWupTSoAFW%2B%3DqnFPQfj_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Saturday, December 30, 2017

Hi!

I'm pleased to announce the release of active_record_doctor 1.5.0. It can help you to:

- New feature: Detect soft-deletable models with inappropriate indexes
- Detect models referencing undefined tables
- Automatically index foreign keys for better read performance
- Automatically detect missing foreign key constraints to improve database consistency
- Automatically detect extraneous indexes to save space and improve write performance

Installation and usage instruction are available on the project home page: https://github.com/gregnavis/active_record_doctor

If you'd like to submit a feature request or a bug report then feel free to shoot me an email or open an issue on GitHub.

Yours
Greg Navis

--
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/CAA6WWt8-ani_MbeiiPAaRU42X42yZ%3D%2BXAAeE7pXuaZXo%3D253FQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Friday, December 29, 2017

@andre the issue is you are trying to dump walls of code (text) in a single file. The complexity of your application will increase a lot, you will have one BIG simulate method that does everything, such big methods are hard to understand after a few weeks even by the developer that wrote them. In general good code is written in a way that hides complexity from the rest of the system, so, what its actually maintainable is to have code that works by hiding complexity. Something like a model, for example, User.first, its nice to use because its hiding the complexity of connecting to the DB, building the query and mapping record into a ruby object, imagine having that code dumped into each model file, wouldnt it make finding your own code or navigating around different part of the code confusing? now imagine dumping that code directly in the controller, having a controller connect to the DB, build the query and handle the edge case and then loading a ruby object with the returned record? that would surely make controllers a mess, instead of having the short methods like 
```
def index
  @users = User.all
end
```

it would be

```
def index
   HUGE ALL OF CODE THAT NO ONE WANTS TO READ
end
```

you are talking the path of the second example. 


So how is this problem solved? there are several best practices, like encapsulation, and limiting responsibility of what you are putting in a file. In Object Oriented Programming we aim at hiding complexity inside classes, think of classes as kitchens, like the ones in cafeterias,
they have a small window, an order comes in on a small piece of paper and a dish comes out, how the dish is made and how many cooks are in the kitchen is not something that customers or waiter should be concern.  Your controller is a class, it takes one argument calles the 
Request object from rails, that object has the params and session information, the controller uses it to decide if it should respond with success, redirect or deny access. During one of those decisions it might ask a class for a value, and there is a chance that a class is an active record model, but the controller does not know that and does not care where User.first got its value, to the controller its just a ruby object, period. You are trying to change that pattern, you want to make a controller that will calculate a "Simulation" something that might imply a lot of code and needless complexity.

You will have this

```
def simulate
HUGE CHUNK OF CODE THAT YOU WILL NOT UNDERSTAND IN A MONTH FROM NOW
end
```
Instead you should have something like this

```
def simulate
   @simulation = Simulation.new(HomeTeam.new(params[:home_team]), AwayTeam.new(params[away_team]))

   if @simulation.valid? # check if the simulation makes sense inside that method and hide everything from the controller
     flash[:notice] = "this are the results"
  else
    flash[:error] = 'Simulation parameters are invalid'
    redirect_to :show
  end
end
```
In the above example the controller does not know where the simulation values come from, its only responsibility is the decision of where to send the user, this is what rails does, it scopes stuff, this is why its split into model, view and controller, to make your code simpler.
Like it was mentioned by Hassan, you need to read about Object Oriented programming because you are creating a very complex solution for a very simple problem.

Let me finish by saying that if this is a throw away project you are doing to learn, this is the right moment to learn OOP. If you think the reading we suggesting is too much effort for a throw away app you are mistaken, reading/learning OOP will prepare you for your career as a developer since the mistake you are making right here is a very beginners mistake and it will show in any job you apply to.





On Mon, Dec 25, 2017 at 9:35 PM, André Luiz Abdalla Silveira <andreluizsa00@gmail.com> wrote:
First of all, Happy holidays to you folks.
Secondly, I'd like to deeply appreciate the help you're giving me

Hassan, I'll search for this material you've suggested ^^. But I didn't understand why this doesn't belong to the controller (since it's on the controller), but I hope I can make it clearer at the end of this message. I also have a difficulty on describing my problem as a set of tests, since it's not completely clear to me the complete set of states of execution my app will go through

Radhames, I couldn't understand what you tried to tell me there (copying what you said) --> "the controller is a class that should only be handle handling where to direct the request, not actually performing operations on the data or whatever."

Talking about what I want to do. My long-term goal is to simulate a MLB season game by game (with every kind of play and player).  To achieve it, I want to build a method to simulate a match. By now, and as a short-term goal, I want to produce a generic result, and important for me is building a good algorithm not depending on where to build it (controller, model, or helper -- it sounds a little freak to me to make on the view (I'm doing it, but I swear it's just provisory LOL))

 In a close future, I want to take the simulation to next level, creating a model for pitchers and batters. But again, it's something for future steps.

I know I have a long way to go through on learning Rails, but on groups like these, my learning goes faster
Again, thank you, Hassan and Radhames

Em sábado, 23 de dezembro de 2017 06:03:24 UTC-2, André Luiz Abdalla Silveira escreveu:
Guys, I'm making a baseball league application, and I'm facing some challenges. Biggest of them is trying to make a match simulation method (I didn't think a view was necessary for it). This method is in matches_controller.rb, but again, there isn't any view for that. How do you think I should handle it? Have you ever faced any similar trouble?


PS: I love sports at all, so if you have a hockey application to share (it doesn't have to be written in Rails), please do it

--
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/acd64e74-d9bc-4440-9e51-cdd0ca24d833%40googlegroups.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/CANkJ5gm%2B0-7pB9WKqhigsQA1%2BUdG5ScQ%2BwFTpTq%2BD-Bhx%2BQmaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I'm trying to add my search criteria to my sort_link method that's provided by the Ransack gem. Below is a an example of what I get when debugging the application.


(byebug) ransack_search_object
Ransack::Search<class: Player, base: Grouping <conditions: [Condition <attributes: ["position_id"], predicate: in, values: ["", "5"]>, Condition <attributes: ["measurable_summary_height"], predicate: gteq, values: ["6060"]>], combinator: and>>

(byebug) sort_link(ransack_search_object, "Pos", %i(position_abbreviation), { controller: "players", action: "ransack_search" })
"<a class=\"sort_link \" href=\"/players/ransack_search?q%5Bs%5D=position_abbreviation+asc\">Pos</a>"



As you can see above the search criteria is specified in ransack_search_object, but it doesn't appear in the href link that is generated. I'm not sure why this is the case though.  Anyone have any ideas or suggestions I could try?  Thanks!

--
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/eb778bc5-d154-43e7-abbe-aa085df1cc11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I implemented new Project in Ruby on Rails

In my project I Created page "Announcement" with Topic tittle field,text message field,Attachment field and save button

Whenever I try to create new Announcement,

I enter something in topic title feild,text message feild,attached image in Attachment feild,and finally click the save button,its works properly then it automatically moves to next page

But My Issue is

By clicking the save button with out attaching any image in attachment feild,I Got the error in console tab - "POST XHR http://mydomain/api/v1/courses/1016/discussion_topics" along with "401(unauthorised)"

And In network tab-{"status":"unauthorized","message":"Invalid access token."}

But it work properly few day before.now I'm getting issue.I dont know How to solve??

[pls refer this image][1]

Thanks



  [1]: https://i.stack.imgur.com/0Hpeg.png

--
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/2dccd54f-79c2-4a05-bb9a-7ccf4e4d337e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Thursday, December 28, 2017

Hi All,


Last year was a very successful event and we hope to top that when we hold the 2nd annual RubyHACK conference in Salt Lake City, Utah May 3 / 4 2018.  The CFP is still open until January and we'd like your support!  If you've got fine-tuned presentations or are a beginner wishing to get in front of a supportive group, we may have room for you.  Please submit a CFP at http://rubyhack.com/cfps/new#cfp_page

If you, or anyone you know, might be interested in sponsoring our event this year, please check out the website and let us know.  It's shaping up to be a great event and you could make it even better!

Thanks and Happy New Year!


Max

Ruby on Rails Tuesday, December 26, 2017

On 26 December 2017 at 01:35, André Luiz Abdalla Silveira
<andreluizsa00@gmail.com> wrote:
> First of all, Happy holidays to you folks.
> Secondly, I'd like to deeply appreciate the help you're giving me
>
> Hassan, I'll search for this material you've suggested ^^. But I didn't
> understand why this doesn't belong to the controller

Remember that a model does note need to be backed by a database table.
There should not be any significant logic in a view or controller.
It is much easier to test logic (algorithms) if they reside in a model.

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%3D0gLvi-PwtenjfVSkLC-%3DpD5R9XE_o0HyNY70DuEhQtFmY4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Mon, Dec 25, 2017 at 5:35 PM, André Luiz Abdalla Silveira
<andreluizsa00@gmail.com> wrote:

> But I didn't understand why this doesn't belong to the controller

Business logic doesn't belong in controllers, it belongs in models or
service objects. It's accepted good practice and makes testing much
much easier. Reading up on the MVC pattern would probably be a
good thing too.

> also have a difficulty on describing my problem as a set of tests, since
> it's not completely clear to me the complete set of states of execution my
> app will go through

Writing tests is a way to explore the problem space, it doesn't mean
having a completely architected solution first.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
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/CACmC4yB0Br4sN0sK%3D4F1T3cCHDDtTpqm97nwNJT90_46NAnB7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Monday, December 25, 2017

First of all, Happy holidays to you folks.
Secondly, I'd like to deeply appreciate the help you're giving me

Hassan, I'll search for this material you've suggested ^^. But I didn't understand why this doesn't belong to the controller (since it's on the controller), but I hope I can make it clearer at the end of this message. I also have a difficulty on describing my problem as a set of tests, since it's not completely clear to me the complete set of states of execution my app will go through

Radhames, I couldn't understand what you tried to tell me there (copying what you said) --> "the controller is a class that should only be handle handling where to direct the request, not actually performing operations on the data or whatever."

Talking about what I want to do. My long-term goal is to simulate a MLB season game by game (with every kind of play and player).  To achieve it, I want to build a method to simulate a match. By now, and as a short-term goal, I want to produce a generic result, and important for me is building a good algorithm not depending on where to build it (controller, model, or helper -- it sounds a little freak to me to make on the view (I'm doing it, but I swear it's just provisory LOL))

 In a close future, I want to take the simulation to next level, creating a model for pitchers and batters. But again, it's something for future steps.

I know I have a long way to go through on learning Rails, but on groups like these, my learning goes faster
Again, thank you, Hassan and Radhames

Em sábado, 23 de dezembro de 2017 06:03:24 UTC-2, André Luiz Abdalla Silveira escreveu:
Guys, I'm making a baseball league application, and I'm facing some challenges. Biggest of them is trying to make a match simulation method (I didn't think a view was necessary for it). This method is in matches_controller.rb, but again, there isn't any view for that. How do you think I should handle it? Have you ever faced any similar trouble?


PS: I love sports at all, so if you have a hockey application to share (it doesn't have to be written in Rails), please do it

--
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/acd64e74-d9bc-4440-9e51-cdd0ca24d833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Thanks for your reply. I am seeing this in production. I thought connection pool will be maintained for the run time of application too but looking at the establish_connection source code it looks like it clears the existing pools and creates a new connection pool. I thought it would be checking if there is already a connection pool existing for the spec and if not then create the connection pool.
This makes me wonder if its a good idea to cache connection pool in an ivar in my application when Active Record decided not to do it.


On Friday, December 22, 2017 at 9:03:13 AM UTC-6, Walter Lee Davis wrote:
Are you seeing this in development or production? I would expect this behavior in development, but never in production. In my experience, connection pools are established and maintained for the run-time of the application. Naturally, if you are deployed in an auto-scaling environment, each instance of your app will get its own pool(s), but that's to be expected.

Walter

> On Dec 21, 2017, at 9:11 AM, vaibhav paliwal <vaibhav....@gmail.com> wrote:
>
> Hi,
>
> In our rails application we need to establish connection to database based on the client id in the URL. Currently we are using establish_connection but it looks like it creates new connection pool each time and executes some queries to get schema information about DB. Is there a way to cache connection pool ? I am also curious why did Active Record decided not to cache the connection pools based on configuration ? I am not sure if its a great idea to subclass ConnectionHandler and roll my own connection pool caching something like this any opinions ?
>
> Thanks
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/52905ce6-8bc9-422f-becd-ab8609cfc7f2%40googlegroups.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/21f287aa-454a-4e13-8873-cff7d3b8a41c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, December 24, 2017

On 23 December 2017 at 14:02, Robert Phillips
<robert.phillips37@gmail.com> wrote:
> I've got the program in chapter 2.
>
> is there anything i can type in the console to reset the id? I can do e.g.
> User.delete_all and delete all users, but if a new user is then created it
> doesn't have an id of 1 'cos the id doesn't reset.

To add to what others have said, if you want an id you can reference
that you have full control over then add another field for that, the
standard id field is not even guaranteed to start at 1 and increment
uniformly, different databases may generate ids in different ways.

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%3D0gLsPyKs1H1LzaD0Vju%3DdJfivEKfkTOkviwLSOBnJCAPgHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Saturday, December 23, 2017

Hi andre, like hassan is pointing out, your code wil become very needlessly complex pretty soon because you are not separating responsibilities or the classes, the controller is a class that should only be handle handling where to direct the request, not actually performing operations on the data or what ever. If you keep going that route the controller will become a huge procedural app in itself. You should have something like this there

```
Match.new(params[:match_data]).simulate()
```

And then simulate should hide all that complexity from the controller.

In any case, please explain better the problem you are trying to solve.

On Fri, Dec 22, 2017 at 8:16 PM, André Luiz Abdalla Silveira <andreluizsa00@gmail.com> wrote:
Guys, I'm making a baseball league application, and I'm facing some challenges. Biggest of them is trying to make a match simulation method (I didn't think a view was necessary for it). This method is in matches_controller.rb, but again, there isn't any view for that. How do you think I should handle it? Have you ever faced any similar trouble?


PS: I love sports at all, so if you have a hockey application to share (it doesn't have to be written in Rails), please do it

--
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/dc886a29-58d4-497a-a7dd-a29370b84dfd%40googlegroups.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/CANkJ5gnkDVLMCxa8cuwk-aWfr7sxwu47gaFd9Ho4su3CoC5xEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Fri, Dec 22, 2017 at 4:16 PM, André Luiz Abdalla Silveira
<andreluizsa00@gmail.com> wrote:

> Biggest of them is trying to make a match simulation method (I
> didn't think a view was necessary for it). This method is in
> matches_controller.rb, but again, there isn't any view for that. How do you
> think I should handle it?

I think you should read as much as possible about Object-Oriented
programming right away :-)

"Practical Object-Oriented Design in Ruby (POODR)" by Sandi Metz
is a good intro, but there are lots of other resources online.

That "simulate" method does NOT belong in a controller, it belongs
in a model, and I would also recommend you step back and try to
describe the problem(s) you're trying to solve in the form of tests,
breaking the steps down as much as possible. Flowcharting on a
whiteboard or sheet of paper might be useful too.

Good luck!

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
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/CACmC4yAQ7FbUS06VZOoxF7ms0F-Dc8AcSy8DBFKJW4r5DYSBUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sat, Dec 23, 2017 at 6:02 AM, Robert Phillips
<robert.phillips37@gmail.com> wrote:

As Walter already pointed out, you shouldn't care about the content
of the id field, but ...

> I get this error
>
> C:\rubyarud\hartl\ch2\toy_app>rails db:drop
> Permission denied @ unlink_internal - C:/rubyarud/h
> Couldn't drop database 'db/development.sqlite3'
> rails aborted!
> Errno::EACCES: Permission denied @ unlink_internal

I would be concerned about not being able to drop and recreate a
database -- sometimes when you're experimenting you *will* get to
a place where you want a clean slate.

That said, I have no idea about Windows permissions; my guess
would be you have the DB open in some other process, but beyond
that -- no idea.

Good luck!
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
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/CACmC4yBDrLv%2BeW7ffjmwHoKnm0mwtktQi3sXSq9ywBJrkLjnQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

The id is coming from an auto-increment column in your database. There are two options if you want to reset to start at 1:

* You can roll back your migrations until you drop the table,
* or your can use SQL: truncate table [your_table_name] in a SQL console.

Really, though, the numerical ID is utterly meaningless, so it's not clear why you would care that the ID start back at 1 or not. It matters to the database, because it's the primary key, so there's a real need for it to never repeat ever. But unless you're worried about a few digits in a 64-bit numberspace... You have larger issues to worry about if you ever hit the end of that possible id value.

Walter

> On Dec 23, 2017, at 9:02 AM, Robert Phillips <robert.phillips37@gmail.com> wrote:
>
> I've got the program in chapter 2.
>
> is there anything i can type in the console to reset the id? I can do e.g. User.delete_all and delete all users, but if a new user is then created it doesn't have an id of 1 'cos the id doesn't reset.
>
> this User.reset_primary_key doesn't work either.
>
> Notice how I removed all users I reset the primary key, I added a user, and they got quite a high id.
> irb(main):064:0> User.first
> User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY "user
> => nil
> irb(main):065:0> User.primary_key
> => "id"
> irb(main):066:0> User.reset_primary_key
> => "id"
> irb(main):067:0> User.first
> User Load (0.0ms) SELECT "users".* FROM "users" ORDER BY "user
> => #<User id: 13, name: "f", email: "f", created_at: "2017-12-23 0
> irb(main):068:0>
>
>
>
> I get this error
>
> C:\rubyarud\hartl\ch2\toy_app>rails db:drop
> Permission denied @ unlink_internal - C:/rubyarud/h
> Couldn't drop database 'db/development.sqlite3'
> rails aborted!
> Errno::EACCES: Permission denied @ unlink_internal
> bin/rails:4:in `require'
> bin/rails:4:in `<main>'
> Tasks: TOP => db:drop:_unsafe
> (See full trace by running task with --trace)
>
>
>
> I notice the error mentions sqlite. I'm using the correct gem file, I think. https://pastebin.com/E2R77amU I know the gemfile in the book that we are to use moves sqlite into the development and test groups. I have that and am using the gemfile that the book gives.
>
> Is there anything I can do from the console to reset it?
>
> Thanks
>
>
> --
> 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/128e2eaa-2168-4ae9-b1fc-bcabcbb7a39a%40googlegroups.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/88CAF5E2-447F-4EE7-840C-D3D63FA60D2A%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I've got the program in chapter 2.

is there anything i can type in the console to reset the id? I can do e.g. User.delete_all  and delete all users, but if a new user is then created it doesn't have an id of 1 'cos the id doesn't reset.

this User.reset_primary_key   doesn't work either.

Notice how I removed all users I reset the primary key, I added a user, and they got quite a high id.
irb(main):064:0> User.first    User Load (1.0ms)  SELECT  "users".* FROM "users" ORDER BY "user  => nil  irb(main):065:0> User.primary_key  => "id"  irb(main):066:0> User.reset_primary_key  => "id"  irb(main):067:0> User.first    User Load (0.0ms)  SELECT  "users".* FROM "users" ORDER BY "user  => #<User id: 13, name: "f", email: "f", created_at: "2017-12-23 0  irb(main):068:0>


I get this error

C:\rubyarud\hartl\ch2\toy_app>rails db:drop  Permission denied @ unlink_internal - C:/rubyarud/h  Couldn't drop database 'db/development.sqlite3'  rails aborted!  Errno::EACCES: Permission denied @ unlink_internal  bin/rails:4:in `require'  bin/rails:4:in `<main>'  Tasks: TOP => db:drop:_unsafe  (See full trace by running task with --trace)


I notice the error mentions sqlite. I'm using the correct gem file, I think. https://pastebin.com/E2R77amU   I know the gemfile in the book that we are to use moves sqlite into the development and test groups. I have that and am using the gemfile that the book gives.

Is there anything I can do from the console to reset it?

Thanks

--
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/128e2eaa-2168-4ae9-b1fc-bcabcbb7a39a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Friday, December 22, 2017

Guys, I'm making a baseball league application, and I'm facing some challenges. Biggest of them is trying to make a match simulation method (I didn't think a view was necessary for it). This method is in matches_controller.rb, but again, there isn't any view for that. How do you think I should handle it? Have you ever faced any similar trouble?

Git repository: https://github.com/dede999/myMLB

PS: I love sports at all, so if you have a hockey application to share (it doesn't have to be written in Rails), please do it

--
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/dc886a29-58d4-497a-a7dd-a29370b84dfd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On Dec 22, 2017, at 11:00 AM, belgoros <s.cambour@gmail.com> wrote:
>
>
>
> On Friday, 22 December 2017 16:58:30 UTC+1, Walter Lee Davis wrote:
> Precisely. There's <strike>a</strike> MANY RailsCast(s) about it, long out of date, but still relevant enough to give you the basic idea of how it works.
>
> http://railscasts.com/episodes?utf8=✓&search=omniauth
>
> Walter
>
> Yes, I saw it, - as you noticed, most of them are outdated. Thank you!
>

Well worth watching anyway, they give you the gist of how to integrate, even if you need to translate up to modern idiom in places. It's like learning on hand tools, and then graduating to the machine shop!

Walter

> > On Dec 22, 2017, at 10:08 AM, belgoros <s.ca...@gmail.com> wrote:
> >
> > Thanks a lot Walter. Did you mean OmniAuth gem ?
> >
>
>
> --
> 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/7ccd0027-1257-4045-b159-fced74928411%40googlegroups.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/DC920ABF-526F-409E-849A-DB21EAE81AFB%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, 22 December 2017 16:58:30 UTC+1, Walter Lee Davis wrote:
Precisely. There's <strike>a</strike> MANY RailsCast(s) about it, long out of date, but still relevant enough to give you the basic idea of how it works.

http://railscasts.com/episodes?utf8=✓&search=omniauth

Walter

Yes, I saw it, - as you noticed, most of them are outdated. Thank you! 

> On Dec 22, 2017, at 10:08 AM, belgoros <s.ca...@gmail.com> wrote:
>
> Thanks a lot Walter. Did you mean OmniAuth gem ?
>

--
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/7ccd0027-1257-4045-b159-fced74928411%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Precisely. There's <strike>a</strike> MANY RailsCast(s) about it, long out of date, but still relevant enough to give you the basic idea of how it works.

http://railscasts.com/episodes?utf8=✓&search=omniauth

Walter

> On Dec 22, 2017, at 10:08 AM, belgoros <s.cambour@gmail.com> wrote:
>
> Thanks a lot Walter. Did you mean OmniAuth gem ?
>

--
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/DFEF752E-DBE8-4B34-B9EE-1D86DCD33688%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, 22 December 2017 16:05:09 UTC+1, Walter Lee Davis wrote:
Have you looked at OmniAuth yet? That's how I would try to connect to an OAuth provider. There is a Devise strategy for OmniAuth. All the documentation you will find will show you how to connect via Facebook or Twitter or whatnot, but it's the same drill no matter which provider you choose.

Walter
Thanks a lot Walter. Did you mean OmniAuth gem

> On Dec 22, 2017, at 3:51 AM, belgoros <s.ca...@gmail.com> wrote:
>
> I have a corporate OAuth 2.0 API that every application should use to authenticate its users. This API requires a request to have the following parameyers:
>         • response_type : must be set to "token"
>         • client_id : client identifier for the application
>         • redirect_uri : URI for the callback
>         • state :  a random value used by the client to maintain state between the request and callback
> Example:
>
> HTTP GET
> https://corporate.auth.com/authorize?response_type=token&client_id=mySinglePageApp&state=myAppRandomState&redirect_uri=http%3A%2F%2Fmyapp%2Fcallback
>
> If the user is not authenticated, the standard corporate login page is displayed to enter user name and password.
> If the user is authenticated after submitting the his user name and password, he is redirected to the client callback URL with an API generated token:
>
> HTTP 302 Redirect
> Location https://myapp/callback#access_token=2YotnFZFEjr1zCsicMWpAA&type=Bearer&expire_in=3600&state=myAppRandomState
>
>
> What is the way to go to connect a Rails app to this API ? Should I the use the Devise gem for that ? Any other solutions ?
>
> Thank you!
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/42651038-d802-4e1d-bdb6-8b89cf6e8f38%40googlegroups.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/542f05cf-b0b2-4e50-a677-5c9db3f3d8ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.