http://stackoverflow.com/questions/4333393/using-rails-generate-scaffold-when-model-already-exists
--
My next question is whether it is possible to sue the amazing Rails generators - in particular, scaffold - to more quickly create an app that works with an existing database - so it would not be necessary to go thru all those manual steps shown above. I tried it once, and it tried to run the migrator and croaked when it found that the DB table was already there. But that may have been pilot error on my part. Comments and advice would be welcome.
~ Ken
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/4a506cc5-5bf7-4f46-9628-b4dc6e7555b2%40googlegroups.com.
--
Jibun no Tame ni Warette Iru
( Aqua Timez - Alones )
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/CANryp8kCTcsTGhPaqtZ1PpmVsSqaW%2BQY18JA2qwnkG%3DnharJbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
This first experiment used (a) the simplest "instructions" I could find (basically, Hassan's); (b) a streamlined version of the "Getting Started Guide" process for setting up a Rails app (but - this is crucial - omitting the step of running the migrator); and (c) a pre-existing ("legacy") database that conforms to the Rails naming conventions.
For the benefit of other Rails newbies (or oldbies) that need to build apps on existing DBs, a play-by-play of what I did follows.
1. Created new Rails app, x:
[sunward@web324 rails_eval]$ rails new x
2. Populated the "legacy" SQLite database with table toys, and added one row to that table:
[sunward@web324 x]$ rails dbconsole
SQLite version 3.6.20
sqlite> CREATE TABLE toys ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" TEXT);
sqlite> INSERT INTO toys (name) VALUES ("Tinker");
sqlite> SELECT * FROM toys;
1|Tinker|58
3. Added the toys resource and root to routes.rb:
Rails.application.routes.draw do
resources :toys
root 'toys#index'
end
4. Used rake to see the resulting routes:
[sunward@web324 x]$ rake routes
Prefix Verb URI Pattern Controller#Action
toys GET /toys(.:format) toys#index
POST /toys(.:format) toys#create
new_toy GET /toys/new(.:format) toys#new
edit_toy GET /toys/:id/edit(.:format) toys#edit
toy GET /toys/:id(.:format) toys#show
PATCH /toys/:id(.:format) toys#update
PUT /toys/:id(.:format) toys#update
DELETE /toys/:id(.:format) toys#destroy
5. Generated toys controller:
[sunward@web324 x]$ rails generate controller toys
create app/controllers/toys_controller.rb
invoke erb
create app/views/toys
invoke test_unit
create test/controllers/toys_controller_test.rb
invoke helper
create app/helpers/toys_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/toys.coffee
invoke scss
create app/assets/stylesheets/toys.scss
6. Added the necessary CRUD methods to the toys controller:
class ToysController < ApplicationController
def index
@toys = Toy.all
end
def show
@toy = Toy.find(params[:id])
end
def new
@toy = Toy.new
end
def create
@toy = Toy.new(toy_params)
if @toy.save
redirect_to @toy
else
render 'new'
end
end
def edit
@toy = Toy.find(params[:id])
end
def update
@toy = Toy.find(params[:id])
if @toy.update(toy_params)
redirect_to @toy
else
render 'edit'
end
end
def destroy
@toy = Toy.find(params[:id])
@toy.destroy
redirect_to toys_path
end
private
def toy_params
params.require(:toy).permit(:name)
end
end
7. Made index.html.erb, show.html.erb, new.html.erb, edit.html.erb, _form.html.erb, index.json.jbuilder, show.json.jbuilder, following the pattern in http://guides.rubyonrails.org/getting_started.html.
8. Created the Toy model file, toy.rb:
class Toy < ActiveRecord::Base
end
9. In my browser, tried http://x.sunward.webfactional.com/toys. Feel free to try it yourself. (However, this is a temporary site that may be gone by the time you read this.) It works!!! That is, all the CRUDs execute as they should.
10. An odd note is that there still is no schema.rb file in x/db/. If this is what Rails uses as its "database catalog", is the lack of it going to cause trouble down the road?
Thanks again to Scott, Hassan, & Colin for your key clues.
My next question is whether it is possible to sue the amazing Rails generators - in particular, scaffold - to more quickly create an app that works with an existing database - so it would not be necessary to go thru all those manual steps shown above. I tried it once, and it tried to run the migrator and croaked when it found that the DB table was already there. But that may have been pilot error on my part. Comments and advice would be welcome.
~ Ken
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/4a506cc5-5bf7-4f46-9628-b4dc6e7555b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On May 30, 2015, at 11:57 PM, Charles Denison <lists@ruby-forum.com> wrote:
> I'm new to Rails...using RubyMine as an IDE.
>
> I have Paper_Trail saving previous versions of the data "xoi_qb". My
> view is currently showing the current and previous data as I'd like, but
> I would like to show the diff between the current version "xoi_qb" and
> the previous version "xoi_qb". For instance, the current version may be
> "97" and the previous version may be "94", and I would like to display
> "+3". I would like to display this difference and add the "+" or "-"
> based on the positive or negative change.
>
> In my model, Paper Trail is set to create versions like this:
>
> def get_xoi_qb
> xoi_qb = [ ]
> self.versions.each do |version|
> unless version.reify.nil?
> xoi_qb << version.reify.xoi_qb
> end
> end
> return xoi_qb
> end
> And in my HTML set to display the versions like this:
>
> <th>Previous XOI</th>
> <table>
> <% @quarterback.versions.each do |version| %>
> <tr>
> <td><%= version.reify.xoi_qb %> dated <%= version.created_at
> %></td>
> </tr>
> <% end %>
>
> Not sure how to show the difference between the two versions.
Paper Trail saves a diff, but not at the level you're thinking of. Instead of calculating the new value from the old plus the diff, it saves the attributes that are different from one object to the next. For example, if you had Widget.create( size: 'large', color: 'blue') and you changed it to color: 'green' later, the object that Paper Trail saved to record this change would consist of only the color: 'blue' part, the updated_at from the initial creation of the widget, and a foreign key back to the original @widget. The updated @widget record would now consist of size: 'large', color: 'green', and a new updated_at. When you navigate back to the original version, Paper Trail first loads the current value, then overloads any attribute key/value pairs stored in its version record to restore back to the desired snapshot of the object.
You'll have to calculate the difference (through addition or subtraction) yourself. If you think about it, this is only natural, since for Paper Trail to save a true diff at the level you're thinking of, it would have to understand every possible attribute type and value scheme. Much of what people use this for is non-numeric data.
Walter
>
> Really appreciate the 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/b3e22e5b73b4bc08835d4895f438d060%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/4DBB2D3F-568A-467F-8902-2C79FD72C9C2%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
I'm new to Rails...using RubyMine as an IDE.
I have Paper_Trail saving previous versions of the data "xoi_qb". My
view is currently showing the current and previous data as I'd like, but
I would like to show the diff between the current version "xoi_qb" and
the previous version "xoi_qb". For instance, the current version may be
"97" and the previous version may be "94", and I would like to display
"+3". I would like to display this difference and add the "+" or "-"
based on the positive or negative change.
In my model, Paper Trail is set to create versions like this:
def get_xoi_qb
xoi_qb = [ ]
self.versions.each do |version|
unless version.reify.nil?
xoi_qb << version.reify.xoi_qb
end
end
return xoi_qb
end
And in my HTML set to display the versions like this:
<th>Previous XOI</th>
<table>
<% @quarterback.versions.each do |version| %>
<tr>
<td><%= version.reify.xoi_qb %> dated <%= version.created_at
%></td>
</tr>
<% end %>
Not sure how to show the difference between the two versions.
Really appreciate the 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/b3e22e5b73b4bc08835d4895f438d060%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
That's Rosie the Racing Poodle. That photo was taken when she was about a year old, and she's 8 or 9 now, but still very friendly and active. She is a very sweet and funny dog, for sure.
Walter
On May 30, 2015, at 12:14 PM, Taras Matsyk <lists@ruby-forum.com> wrote:
> Hey, if this is your pet on a profile - then
> you have a nice dog, it looks very friendly and funny!
--
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/6B612498-F11F-434E-AE8E-924A41FFD78E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Hi,
Open gem file and change https to http in "https://rubygems.org/gems/jquery-rails-4.0.3.gem". And update bundle.
--
On Friday, 8 May 2015 10:25:55 UTC-4, mnz hz wrote:
rails new xxx
...
Using jbuilder 2.2.13
Gem::RemoteFetcher::FetchError: Errno::ECONNABORTED: An established connection was aborted by the software in your host machine. - SSL_connect (https://rubygems.org/gems/jquery-rails-4.0.3.gem
)
An error occurred while installing jquery-rails (4.0.3), and Bundler cannot
continue.
Make sure thatgem install jquery-rails -v '4.0.3'
succeeds before bundling.Hard to say for sure, but you may want to try these troubleshooting steps:--Matt Jones
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/282bfc07-230f-45de-8ebc-927ffc4db82b%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/CAJP0RPxX_5ELK5Af97%2BWSJYKwMkZOK2W83jspp-GtjmNSWpqKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Thank you, Walter!
Now it makes more sense. Hey, if this is your pet on a profile - then
you have a nice dog, it looks very friendly and funny!
--
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/a5d6f3e69331cebc26facfa98f69632e%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
Em sábado, 30 de maio de 2015 03:52:57 UTC-3, Maxwell Levine escreveu:
Hey all, my company is hiring a Ruby backend developer for our native iOS app. If interested in learning more please email max@shimmur.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/cdcbbadb-842f-45b2-8364-db2491c6e9b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Saturday, 30 May 2015 12:22:57 UTC+5:30, Maxwell Levine wrote:
Hey all, my company is hiring a Ruby backend developer for our native iOS app. If interested in learning more please email max@shimmur.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/697b99ea-40dd-4df7-bbd7-679b2b63ba94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 29 May 2015 at 18:44, joe@via.net <joe@via.net> wrote:
> I would like to fetch some database info. I have to construct a url with
> arguments, send it then parse the returned XML.
>
> I quick example would be nice, but if someone could point out how to do the
> following tasks, I could probable figure it out.
>
> 1) Performng a http 'fetch'
Is this to run as a background task or from the command line or from a
user request to a rails app?
>
> 2) Parking XML. There must me a library or gem for this...
I assume you mean parsing :) Have a look at nokigiri. In fact I
believe that will fetch it from a url for you. The answer to question
1 is still important as it is not advisable to run code fetching from
a url in a request from a user. No doubt when you googled for ruby
xml parsers you found others, they may well be perfectly acceptable
but I have not tried any of them.
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%3D0gLuLcEfQKdKq3GHpH%3DJGcim%3DoBBzd2Chr0xyDqk1cU7%2BJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hi all,
I published a post with some stuff I found worth mentioning about Ruby & Rails.
http://www.arubystory.com/2015/05/cool-stuff-tips-s15e01.html
Cheers
--
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/51034c40-932c-4a3c-b232-f62d8028551a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
has_many :pages,
-> { order(position: :asc) },
inverse_of: :book
accepts_nested_attributes_for :pages
belongs_to :post, inverse_of: :content_sections
validates :post, presence: true
.
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/1bbc4c75-41d1-485e-a1a5-322d5a5605de%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/b5125321-11e2-40b7-a7e3-9cd2d30816e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hashes enumerate their values in the order that the corresponding keys were inserted.
--Hi, I have this hash:hash = { 4049=>[4133, 100], 5814=>[4075, 84], 382543=>[4064, 74], 382544=>[4065, 99], 382545=>[4066, 75] }I need to sort (DESC) this hash by the second item of array.Example: 100, 84, 74, 99, 75How can I solve this problem ? I'm using sort method but can't work it out.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/3ea488c8-cd97-4f03-b31e-f27b44c009ee%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/CAMEJyivM1EsSa4572n32G09A4CRD70Zcxm3N%2Bb5BOCsAirzaRw%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/7dc85982-078e-4418-ab57-87f8a90fdaad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 2015-May-29, at 09:24 , Gm <javaplayer@gmail.com> wrote:
> Hi, I have this hash:
>
> hash = { 4049=>[4133, 100], 5814=>[4075, 84], 382543=>[4064, 74], 382544=>[4065, 99], 382545=>[4066, 75] }
>
> I need to sort (DESC) this hash by the second item of array.
> Example: 100, 84, 74, 99, 75
>
> How can I solve this problem ? I'm using sort method but can't work it out.
>
> Thanks.
Well, assuming that you know a Hash isn't really sortable and you'll end up with an Array (of Arrays)...
irb2.2.2> hash = { 4049=>[4133, 100], 5814=>[4075, 84], 382543=>[4064, 74], 382544=>[4065, 99], 382545=>[4066, 75] }
#2.2.2 => {4049=>[4133, 100], 5814=>[4075, 84], 382543=>[4064, 74], 382544=>[4065, 99], 382545=>[4066, 75]}
irb2.2.2> hash.sort_by {|k,v| v[1]}
#2.2.2 => [[382543, [4064, 74]], [382545, [4066, 75]], [5814, [4075, 84]], [382544, [4065, 99]], [4049, [4133, 100]]]
irb2.2.2> hash.sort_by {|k,v| v[1]}.reverse
#2.2.2 => [[4049, [4133, 100]], [382544, [4065, 99]], [5814, [4075, 84]], [382545, [4066, 75]], [382543, [4064, 74]]]
irb2.2.2> hash.sort_by {|k,v| -v[1]}
#2.2.2 => [[4049, [4133, 100]], [382544, [4065, 99]], [5814, [4075, 84]], [382545, [4066, 75]], [382543, [4064, 74]]]
You really want Hash#sort_by
-Rob
--
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/97435771-D2FE-432F-8B65-371DF693B404%40agileconsultingllc.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/6594e859-f650-4f39-9e88-5061465a693f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On May 29, 2015, at 7:24 AM, Gm <javaplayer@gmail.com> wrote:
>
> I need to sort (DESC) this hash by the second item of array.
> Example: 100, 84, 74, 99, 75
>
> How can I solve this problem ? I'm using sort method but can't work it out.
You can't really sort a regular hash—by definition a hash is unordered. So what output do you want? Possibly an array structured (I'm not showing it sorted) something like: [[4049,[4133,100]],[5814,[4075,84]]…]. Rails provides a kind of hybrid thing, OrderedHash, which you could build—but you'd have to build an array and then sort it anyway in order to be able to insert items into an OrderedHash in sort order.
--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice
--
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/B26AE3AA-CD6B-48B4-9EF9-DCA4ABD23503%40elevated-dev.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/3ea488c8-cd97-4f03-b31e-f27b44c009ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Friday, May 29, 2015 at 9:06:58 AM UTC-4, Cody Skidmore wrote:
You should probably use Devise & Cancan.They're pretty easy to use and very powerful.
On Thursday, May 28, 2015 at 2:26:39 PM UTC-4, kernelre...@gmail.com wrote:Hello,
I'm currently try to develop my first web application in Ruby on Rails for
myself.
I made a user model with a "role" integer in the database to determine if a user
is:
- Guest
- Editor
- Administrator
I'm using an enum in the model to manage roles availables.
I don't know if it is a good choise ?
Like a CMS, my application manage articles.
- A Guest user can see some private articles and
post comments like in a blog.
- An editor is like a guest user but can write articles.
- Administrator can write article and can manage users, attribute roles...
I would like an admin panel only for admin users.
I thought to implement that with an admin namespace and specifics controllers for
admin actions, in this namespace.
About Editor and Guest, I don't know it I should also create differents namespaces ?
Is this practise is a good choise to be conform with Rails principles (DRY, REST full) ?
I would like to know what would be the bests practise in Rails way to implement that.
Your tips or recommendations are welcome ;) ! I would like to learn the best pratices in
Ruby on Rails !
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/3d245f0c-8fbe-4490-b993-255577d32bed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thursday, May 28, 2015 at 2:26:39 PM UTC-4, kernelre...@gmail.com wrote:
Hello,
I'm currently try to develop my first web application in Ruby on Rails for
myself.
I made a user model with a "role" integer in the database to determine if a user
is:
- Guest
- Editor
- Administrator
I'm using an enum in the model to manage roles availables.
I don't know if it is a good choise ?
Like a CMS, my application manage articles.
- A Guest user can see some private articles and
post comments like in a blog.
- An editor is like a guest user but can write articles.
- Administrator can write article and can manage users, attribute roles...
I would like an admin panel only for admin users.
I thought to implement that with an admin namespace and specifics controllers for
admin actions, in this namespace.
About Editor and Guest, I don't know it I should also create differents namespaces ?
Is this practise is a good choise to be conform with Rails principles (DRY, REST full) ?
I would like to know what would be the bests practise in Rails way to implement that.
Your tips or recommendations are welcome ;) ! I would like to learn the best pratices in
Ruby on Rails !
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/e41ca6f0-6682-4a2f-b8fc-ba99fc316979%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wednesday, May 27, 2015 at 1:11:54 PM UTC-4, Rafael s wrote:
Currently I'm trying use a statement IF (If a button appears in the page, then run the IF), see the method Login in the system:
If the button doesn't appear in the page, I would like to run the next method Remove and add new expense
require "selenium-webdriver" require "rspec" require "rspec/expectations" describe "#Add simple expense and after add a receipt", :suitee => true do before(:all) do @driver = Selenium::WebDriver.for :chrome @base_url = "http://sitetest.com" @driver.manage.window.maximize end it "Login in the system" do @driver.get(@base_url) @driver.find_element(:id, "user_email").send_keys "raf...@gmail.com" @driver.find_element(:id, "user_password").send_keys "123456" @driver.find_element(:name, "commit").click if(@driver.find_element(:css, ".btn.btn-lg.btn-success.btn-
block" ).displayed?) @driver.find_element(:css, ".btn.btn-lg.btn-success.btn-block" ).click @driver.find_element(:css, ".introjs-button.introjs-skipbutton" ).click @driver.find_element(:css, ".i.i-pencil").click end end it "Remove and add new expense" do begin while(@driver.find_element(:css , ".i.i-pencil.icon").displayed?) button = @driver.find_element(:id, "expense-bulk-select") @driver.action.click(button).perform delete = @driver.find_element(:id, "delete-multi-btn") @driver.action.click(delete).perform waitDisplayModal = Selenium::WebDriver::Wait.new(: timeout => 10) waitDisplayModal.until {@driver.find_element(:class => "bootstrap-dialog-footer-buttons" )} @driver.find_element(:xpath, "//div[3]/div/div/button[2]").click sleep 3 end rescue Selenium::WebDriver::Error::NoSuchElementError @driver.find_element(:id, "current_expense_merchant").send_keys "Taxi to work" @driver.find_element(:id, "current_expense_amount").send_keys "50" @driver.find_element(:id, "button-add-expense").click waitDisplayIconTrash = Selenium::WebDriver::Wait.new(: timeout => 20) waitDisplayIconTrash.until {@driver.find_element(:css => ".i.i-pencil.icon")} end end after(:all) do @driver.quit end end
My problem: When I run this script, appears this in my console:Failure/Error: if(@driver.find_element(:css, ".btn.btn-lg.btn-success.btn-
block" ).displayed?) Selenium::WebDriver::Error::NoSuchElementError : no such element (Session info: chrome=42.0.2311.135) (Driver info: chromedriver=2.9.248304,platform =Linux 3.13.0-24-generic x86_64)
That is, the IF is not working as I would like. How can I fix it?
CHeers
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/75fab242-55b7-4dac-adbe-825445ebc33a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.