Never use GoDaddy. For anything. Ever.
Use Digital Ocean. Far cheaper than anything GoDaddy offers, FAR FAR better for any real RoR app or any real web app at all.
GoDaddy has AWFUL ethics, AWFUL security and AWFUL...well everything.
There was the time GoDaddy supported SOPA.
Digital Ocean is $5 a month for a VPS, way better.
If you're feeling generous, here is a referral link.
If you're not feeling generous here is a regular link.
I always recommend following The Odin Project's curriculum. It's free and open source, well maintained and updated, comprehensive, and it gives you a very clear path to follow.
Apart from that the community is very active and supportive.
tl;dr Heroku
If you only have 2 people and you don't have prior experience w/ AWS, definitely use Heroku. It is a lot more expensive than AWS, but it's so, so, so much simpler. As you may know, Heroku uses AWS, so it's easily 3+ times more expensive than AWS, but it saves so much time and lets you focus on your product & adding features instead of sys ops or server infrastructure.
Here's an interesting post about the cos of Heroku vs AWSt: https://www.quora.com/Is-it-cheaper-to-deploy-a-Rails-app-to-Heroku-or-AWS
Why would you use MongoDB? PostgreSQL does the same thing, but faster using jsonb
and GIN
indexes: http://www.postgresql.org/docs/9.5/static/datatype-json.html - Why limit yourself to a document store that is only slightly better than writing files to a tmpfs
partition?
Hey Kyle,
Check out this free course from Stanford, Software Engineering for Saas. Starts on the 18th and is quite promising.
I'd agree with looking at Sinatra. Tons of sties and apps have used it, many of them integrating existing APIs.
https://stripe.com/docs/webhooks/best-practices#event-ordering
> Your endpoint should not expect delivery of these events in this order and should handle this accordingly. You can also use the API to fetch any missing objects (e.g., you can fetch the invoice, charge, and subscription objects using the information from invoice.paid if you happen to receive this event first).
Read this: SQLite vs MySQL vs PostgreSQL: A Comparison Of Relational Database Management Systems. That should get you started.
If you're scared about the security of your VPS, follow something like Linode's Securing Your Server guide or one of the Digital Ocean security tutorials
Deploying to your own VPS takes (what certainly feels like) a lot more work than deploying to Heroku. If you're just trying to test out in a production environment and see if your app responds well to real world clients, you might want to give Heroku another look.
PostgreSQL fulltext search is very capable, and since you are on Heroku, you are probably running postgres already.
Have a look at the excellent postgres doku: http://www.postgresql.org/docs/current/static/textsearch-intro.html
I started professionally developing more than 20 years ago; I've also taught many classes, and hired a lot of people for development roles, including in Rails. When I'm hiring someone, I care a lot more about whether they're a good developer than what language or framework they know.
Unless I'm hiring for a serious senior position, the most I expect of a developer is to have a basic understanding of how Rails works, and how it can be refactored. Basically, what I care about is whether they can come up with solutions to programming problems (which are pretty much the same in any language) more than what language they can do it in.
For example, I might ask a few questions about how the backend cycle works in Rails (request to response), building a controller from scratch, refactoring a messy model into better patterns given a few hints, etc.
As far as "MUST HAVE 3 YEARS" - writing job descriptions is hard even when you know exactly what you're looking for - and businesses almost never know what they really want for an employee. Even early in my career, I never paid much attention to the job description. I'm self taught, and most of them absolutely must have a degree in CS - but most of the time they didn't care about my education if we were a good fit.
I wouldn't put too much stock in it - if you like a position and the company, by all means send in a resume, even if they don't have open positions! I've gotten several jobs simply by saying "hey I'm looking for what to do next and your company seems really great, do you have any open positions? Here's my resume."
Long story short - be confident, bold, and don't eliminate yourself from the running before you start.
We use PostMark at work. I don't interact with it too much, but it's free for the first 25,000 emails and offers a built-in templates system (which would eliminate the need for a a bunch of Rails mailer views in your project).
I got the same notice today, and may move in this direction.
No, I think that would be looking for where the text is equal to 'banana', not containing 'banana'
I think you'll want to do something like:
user.comments.where('text ILIKE ?', 'banana').any?
Rough code, typed quickly, might not work exactly
Edit: Stack Overflow link: https://stackoverflow.com/questions/9708409/rails-how-to-find-by-a-field-containing-a-certain-string
I develop offline quite often. Not by choice but because commuting.
It actually taught me to develop much nicer.
It taught me to first read the API documentation and only then search google and stackoverflow. "Google: Rails format money" is a lot less precise and complete than spending 15 minutes reading the docs on how the currency formatter really works in Rails. I got devdocs with offline storage for my API documentation needs.
It taught me to simply bundle open devise
when I encounter yet another weird thing in Devise. And rather than googling it, I now learn how Devise really does things internally, and will often show you that you are using only 10% of a gem and that that part is so simple that you probably don't need that gem at all.
It taught me to simply follow my train of thought and leave a "# TODO: Look up how to connect to a secondary Redis" and continue the actual code instead of getting sidetracked in some weird redis.rb connection singleton configuration.
Edit: After learning that developing offline made me a better developer, not in the last place because it forces focus, I quite consistently work in sprints of 45minutes of uninterrupted developing. Most often without opening my browser at all.
So I had a big long explanation written up to help you better understand MVC, but then I realized that it can be explained with a very simple metaphor:
MVC is kinda like watching TV. The model is the cable company, the controller is the cable box, and the view is the TV screen. You use your remote (let's call that the browser) to send a command to the cable box (like an HTTP request) that says "show me channel 3". The cable box then asks the cable company (the model) for the data on channel 3 and sends it to the TV screen (the view), which assembles the data into pixels and a pretty picture for your eyes to enjoy.
Does that make sense?
Edit: oh, and as far as your actual question goes, your next step depends on one thing - did you actually learn RUBY yet, or did you jump right into Rails? If you jumped right into Rails, immediately stop what you're doing and go find a good book on Ruby (like the "pickaxe book", Programming Ruby from The Pragmatic Programmers). If you did actually learn Ruby already, the next step that I would recommend is to pull up the Rails source code on GitHub and spend a few days just reading through it. You'll learn a lot of best practices, and you'll know EXACTLY what's happening under the hood.
Getting Rails app on an actual hardware is no different than getting it installed on VPS like Linode or Digital Ocean.
Step 1: Install Linux
Step 2: Provision all the softwares: https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma
Step 3: Profit
For provisioning I strongly suggest using something like Ansible. You really don't want to do setup/config by hand.
Also if you have your own hardware I think running VMs on the server is still a good idea. I don't have any experience with that though.
I'd make a partial where you pass local variable `field_name` and `form`, in this case with the value of `:full_name` and `f`. The partial then renders the above.
Also html/erb makes my eyes bleed, so I'd use ruby-slim http://slim-lang.com/
I've used:
highcharts.js http://www.highcharts.com/
ChartDirector; haven't used in a few years but they do have a ruby version: http://www.advsofteng.com/gallery.html
Both worked great for me.
why would you do it the way you're proposing? why wouldn't you use Stripe Connect - it's literally designed to do exactly what you're describing with a lot less transferring between accounts and a lot more charging/depositing directly to accounts.
You can use Leaflet as is, loading the assets via CDN. Or if you prefer to use the asset pipeline and have custom helpers, there's also leaflet-rails.
If you want something simple, pleasant and privacy-friendly, I really like GoAccess, a FOSS program that parses your server logs. At its simplest you just run a single command telling it where the logs are and it generates a fancy HTML report like this. No need to install anything on your website or depend on a third party. And it can't be blocked either, so it's as accurate as you can get.
Alternatively, you can parse the logs yourself fairly easily with a regex. Sample for nginx logs to get the visitor count:
visitors = Set.new # A set of all unique IPs that visited our site File.foreach(log_file) do |line| match = line.match /^([^ ]+) [^ ]+ [^ ]+ [.?] "[^"]" [^ ]+ / if match visitors.add match[1] else raise "Log line doesn't match regex: #{line}" end end puts visitors.count
That's a really good question.
It can make sense in a situation where you'll be JOINing on any of a number of possible attributes. But even then, you can still use WHERE when needed, and SELECT specific values as data.
But the main key factor to consider is, will a non-developer need to update data specific to the charity? If so, then I think it makes a lot of sense to put it in the database. If not, then you probably don't need to.
This is a case where a Ruby object makes sense - no ActiveRecord required. Just make an object with the methods you need, and use it wherever you need it.
class Charity def name "Awesome Charity" end
def address "123 Donation Lane" end end
That object is cheap to instantiate so you don't have to do anything tricky. But there are other things you could do if you wanted, like use class methods instead of instance methods.
You could even just read a value from a config file, and use a global variable or hash.
Personally, I like to use Ruby objects in this case. It provides a natural place to put behavior as you continue to develop your app.
So without knowing more (like whether you anticipate an admin regularly changing data about the charity), I would start with a Ruby object like the one I showed, and then move to a database table if we reach a point where a non-developer needs to be able to update the data.
And if you do use a database, now or in the future, you might consider using a database constraint to ensure there's only ever one record in the charities table.
It’s slightly out of date but almost all of it is still relevant and the best deep dive into Rails I know of: The Rails 5 Way by Obie Fernandez
If cost is your main concern then you shouldn't use Heroku. Get a server at Scaleway, learn to deploy your app manually. Scaleway is ridiculously cheap, even cheaper than Digital Ocean: only 19 EUR/mo (about $22/mo) for an 8 core server with 16 GB RAM. The same hardware would cost you more than $500/mo on Heroku, or $160/mo on Digital Ocean. The only caveat is that Scaleway's servers are in France.
Passenger has an excellent tutorial on deploying a Rails app to your own server: https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/
Make sure SPF, DKIM and DMARC are set up correctly at a minimum. (Google around for these).
However, Amazon has notoriously poor deliverability with their email service. I would recommend using Postmark. Leaps and bounds better than any other service I’ve used (mailgun, sendgrid, and a couple others)
Stripe may be calling your webhook multiple times -- you may want to ensure that you're returning a 2xx code in that method to let Stripe know everything was processed on your end correctly. Otherwise, Stripe will attempt to retry:
Answer 1: Sure, if you need it. Will you have a lot of scenarios where you would want to call @user.games
? If so, then go for it. has_many :through
is basically a convenience method.
Answer 2: You can do this right in your model validations. For example, in game.rb: validates_length_of :players, :in => 5..10, :if => :game_starting?, :message => "This game is at maximum capacity."
Answer 3: You may want to look into the State Machine gem, as it sounds like that fits the design pattern you're looking for.
I would suggest doing this tutorial:
I currently have 2 rails apps, 2 sinatra apps, and 2 node apps all running on the same instance using simple techniques like these:
You can do it on EC2 or DO or whatever and there should be no difference... Or on another system entirely (Ubuntu is what I prefer for simplicity). You'll probably just have to handle package installation differently.
I mean: https://www.heroku.com/pricing
You turn on one hobby-level dyno for your app, and that's $7/month. That won't change unless you change it. Most add-ons (database, logging, whatever) have free-tier options that will probably more more than sufficient for your purposes.
If you end up having enough traffic to require more or better dynos, that's a good problem to have, right?
DigitalOcean has pretty great tutorial resources that you should check out if you haven’t already. You can learn a lot about those topics. For example, for learning about load balancers: https://www.digitalocean.com/community/tutorials/how-to-create-your-first-digitalocean-load-balancer.
You're probably going to want to build rails engines that you use via gems. Take a look at how Devise is built. Each engine gets its own MVC structure that can have pieces be overridden by the application using it.
I use Git as a deployment mechanism, it works wonderfully. I am not a fan of the frequently used capistrano or heroku. Just my two cents... https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
A working way is to get the Postgres.app and then install the gem with an argument for the path to pg_config (might be different for newer versions):
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Postgres is pretty easy to setup these days if you use a mac checkout http://postgresapp.com/
Best to keep your prod and development the same will save you a lot of hassle in the future.
Also as a side note you can use Mysql with heroku you just have to add it as an add-on application.
Like oldman says, it's probably not a good tutorial and you're better off with hartl's one. That being said, here are some explanations for your problems.
>Ok, whatever. Finally have my files on my computer. I try to start the server via the "rails server" command and it doesn't work. Apparently the computer just doesn't know where to find the gems. So I have to go through each gem and do "gem install [gem name] -v [version] --source http://rubygems.org/"
You indeed need to install gems before using them. Nobody manually installs gems anymore, esp. for rails projects. You'll need to use bundler and a Gemfile. If the tut didn't explain this, it's a bad tut.
>However, it's not loading the right page. When I switch to another workspace folder, it loads the same page. And so does the next one. And the next one.
You need to set up routes, in config/routes.rb. Else you'll just visit the same page. I don't know what you mean with different workspace folders. There is no such concept in rails.
>I try to create a new page using the command "rails new testpage". I open the page and... its the same page. What the heck is going on?
This is a new project, not a new page. Where did you do this? It's pretty clear your frustrations are caused by the quality of the tutorial you use.
>I. Don't. Get. It. Why is the template the default template for everything? I never told it to do that! Why is this all so complicated! I just want to learn how to make websites! I feel like I'm just wasting my time finiking with all of this stuff when I should just be learning how to use Ruby and Rails!
You probably set it as something called a layout. The default is in app/views/layout/application.html.erb IIRC. You are probably still in the same project and that's why you see the same page all the time.
So, start with hartl. From the start. To unlearn any mistakes from your current tutorial. It's here: https://www.railstutorial.org/book
There's a couple things that are in this ballpark out there already, the most prominent one I know of is probably Suspenders:
https://github.com/thoughtbot/suspenders
Also, Heroku recently announced a new app.json manifest format which will let you do cool things like:
{ "name": "Ruby on Rails", "addons": ["heroku-postgresql:hobby-dev","postgres"expeditedssl:single", "papertrail"], "description": "A template for getting started with the popular Ruby framework.", "website": "http://rubyonrails.org", "success_url": "/welcome", "env": { "RAILS_ENV": "production", "COOKIE_SECRET": { "description": "This gets generated", "generator": "secret" }, "SETUP_BY": { "description": "Who initiated this setup", "value": "" } }, "scripts": { "postdeploy": "bundle exec rake db:migrate" } }
Which will do all the setup for your when you push your deploy.
To preface this, I'm just a guy who finished his universities introduction to Rails course, so my knowledge of rails is limited, but this is some very basic rails stuff your asking and it sounds like you haven't done much on rails so far.
From my personal experience, it might be more efficient to learn the very basics of creating an app with Rails before asking how to specifically do something. This will save time in the long run.
I suggest checking out this rather quick tutorial on how to create a blog app. So that you understand how to build the individual parts of REST (as it sounds like you want to do anyway), rather than using scaffold to generate code you don't understand.
Also, if you're interested in learning more Rails, then you can try the Odin project. Which helped me understand the basics of Rails. It uses Mike Hartl's rails tutorial a lot for learning code but also has supplementary resources to learning concepts.
opensourcerails.com has some nice examples.
Edit: though personally, I'd recommend Jekyll over "rails". But wether that fits, depends a lot on your requirements. You don't list any, just that it must be rails. Why is that?
This is a common issues in software, so my answer isn't specific to Rails:
Every time you add behaviour for a specific subset of users, you're increasing the complexity of the product. These demands can pull the code in opposing directions, making is more and more difficult to maintain, and eventually slowing down development pace to a crawl. You need to learn when to say "no" to customers, even if that sometimes means turning down potential revenue.
Since it sounds like you haven't released the app yet, focus on getting an initial MVP in front of real customers before trying to anticipate what might be needed in future.
(and I highly recommend reading The Lean Startup if you haven't already).
Can you say what about Heroku has you wanting to move on from it? Just curiosity -- great, learn all you can. But be aware that Heroku is a fine solution. There are even many high profile companies using it, in addition to the many small projects/companies using it. And although I have seen, deployed, and maintain rails on self hosted solutions, it's a much more different topic and more closely related to sysadmin than rails development. And so for many developers, it's just something better left to a PaaS, so it doesn't get as much attention.
That being said, Capistrano seems to be the official scripting solution (see the commented out gem in the Gemfile), and research Capistrano. And you can find tutorials[0] about deployment to a VPS (like Digital Ocean) rather than Paas (like Heroku), and even some container based approaches like docker, and server binaries to choose from.
And as John Carmack says, when you are curious about what approaching to take, just do it both ways and then decide. Side note: I love being able to apply his wisdom from complex shit he does to something comparatively mundane like web dev.
Also would be great to hear back and maybe see a blog post when you finish, since you found them lacking and posted this q!
Lastly to learn the "how and why" is a different subject than the deployment. So as you follow a tutorial, google command line commands you don't understand, and packages you don't understand (like nginx).
[0] Here are 2 to get you started (1 using Puma and 1 using Unicorn) https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma
We use Elastic APM. It's not as good as, eg, newrelic, but it does have good language support, distributed tracing and is pretty easy to set up. Some of the features are paid (as is the elastic.co way) but none that you need for basic APM/exception tracking, imo.
Gitlab implemented a similar policy
> We generally avoid discussing politics or religion in public forums because it is easy to alienate people that have a minority opinion.
I get where it's coming from, but I also think it's possible to discuss politics respectfully without acting condescending towards the minority opinion.
So the example they have here ... what do you think?
Personally I feel iteration #1 is just fine, short and concise. Going all the way to #5 using lambda is just way too much effort. Is this what you want/should to do in real life?
If you want to hack on some popular and very well structured + led open source project that endorses good code architecture, testing and other good principles, check out diaspora*: https://diasporafoundation.org
It's one of the most active Rails projects currently and thus is a good addition to any CV to have submitted some work there.
As as been said this should be done using sockets.
A simple way it can be done for prototyping is to use polling.
setInterval(function() { $.ajax({ url: '/dashboard/fetch_updates/', complete: function(data) { $('#big_skin_jackpot') = $.parseHTML(data); } }); }, 1000 * 10);
Which basically every 10 seconds it would fetch the page at 'dashboard/fetch_updates', and then convert the response to HTML and update #big_skin_jackpot.
Polling does the job you want however it gets very inefficient, if you have 10 users on the site then thats 60 requests a minute, if you have 100 thats 600 requests a minute, plus whatever else the users are doing. Scales terribly and isn't reliable (if people connect at different times your site works fine, but if everyone connects at the same time then your server will be spammed every 10 seconds).
I'd recommend using a WebSockets service such as Pusher very easy to setup. Then you'd do something in your model like:
after_commit :push_updates, only: :create def push_updates Pusher.trigger("user_#{self.user_id}", "item-added", {further: info, regarding: 'your_special_lootz'}) end
Then on your front end:
pusher = new Pusher('YOUR_SECRET_HERE') channel = pusher.subscribe('user_ID_here') channel.bind('item-added', function(data) { do_some_stuff(); })
You'll find a tutorial for building a dating site on codeplace.com.
Usually the Rails community is very helpful. Judging from the other comments, you visited Reddit on a day when everyone was grumpy.
I have just been doing this recently, I would recommend you first focus on getting Redux + React setup in the way you want and as a separate application. To start with you should ignore the database backed side of things, just using mock data where needed.
There is a lot of tools for React available so getting your environment setup can take time itself, personally I followed bits from this guide to get React + Webpack + Babel + Hot Loading (livereload) setup.
Next I'd recommend watching Dan Abramov's introduction to Redux, to get to grips with Redux and implement it in your project. It is worth watching through all 30 videos before integrating it with your project.
Finally you can setup a Rails project which will just serve as an API, then simply integrate your Redux reducers to use the Rails API endpoints that you have created, adjusting the data returns/manipulation as necessary.
Edit: Everything I've suggested is to help make separate React and Rails applications as I believe this is the best method to go down. If you did want to go down a different path (i.e. intregrating React with Rails) then you need to state that but also you shouldn't have a problem finding tutorials on Google for those other methods.
The Odin Project is an excellent way to get started. It includes the resources already mentioned here if that gives you some idea of how thorough it is. I wouldn't normally suggest this, but since you already have an internship and are just trying to get up to speed on a specific technology, if you already know a bit about programming and how to set up your environment you may be able to get away with skipping straight to the Ruby section.
It depends on how dynamic you want the content, and how you want to update it – or more importantly, who you want to update it.
For a blog, most of the content is not intrinsically dynamic. You write a post, and publish it. You may update a post from time to time. Some pages on the site may depend on the published articles – like index pages, tag pages, that sort of thing. But without you, as the publisher, making a change to the site, it’s not really going to change.
From that standpoint, static website generators are a great fit. You maintain a simple publishing workflow, and the website itself runs extremely quickly because it’s just static pages. You don’t have to worry about errors in your application.
A static website doesn’t restrict you from including dynamic elements, either. For example, you could enable comments on your jekyll blog via something like disqus. Drop in some Javascript and let disqus take care of the rest.
You also have the option of creating dynamic web applications backed by the static site, via Rack adapters. For example, I run a site that is published using Jekyll. However, I want to restrict access to specific pages, which I do with a modified branch of jekyll-auth.. Additionally, I’ve written another rack adapter which handles authorization errors, so instead of showing an Octobouncer I can show a sales page.
Personally, I think static website generators like jekyll are a perfect fit for self-published sites like blogs or informational sites. When you don’t depend on multiple users – particularly people who you don’t trust to modify the source of your site – then you can get a lot of mileage from the static site generators, and add any dynamic behavior you need through plugins.
This is really a business question rather than a rails question, however:
If you want some reading that expands on these concepts, I'd recommend "The Lean Startup" and "Rework".
Digital Ocean has some good writeups for deploying, I followed one for another host and it worked out okay, have a few issues with capistrano tbh that I need to find time to squish.
or search Digital Ocean deploying rails and you find a few more versions, leave out the DO term and a bunch of helpful stuff will show up.
Start with learning hosting. Here's a fine start.
Then learn deployment automation next.
Are you using bundler? If not, this stackoverflow answer might help:
How can i find where gems are installed?
If so, you should (after running bundle install) be able to do 'bundle show abc-def' and it will output the path to the location of the files.
It seems really like your include path doesn't include wherever the gem 'abc-def' was installed to. You may want to double-check the usage directions on the gem's github page (or whatever documentation it uses). Some gems need require 'abc-def' or like you put in your post, require 'abc/def'.
We do not guarantee order. Neither do other services like Stripe, as far as I know. In case order is required, the receiving webhook endpoint should reject out-of-order webhooks and rely on retries at a later time until the other event dependencies have been processed. Or the receiver should use certain webhook events as a "signal" and request the missing dependencies within the webhook handler itself.
Edit: Stripe does not guarantee order — https://stripe.com/docs/webhooks/best-practices#event-ordering.
First thing is to get a Postgres client (Postico is great on Macs) and make sure you can connect to the Postgres DB through that. You'll get better error messages and from there you can pull that into the Rails app.
Otherwise /u/r_levan is on the right track, the defaults of the Postgres docker image and the defaults of Rails don't line up. Try what he mentioned and get back to us.
Look into Capistrano for deployment as it's generally bad practice these days to upload your app via FTP.
Try following a tutorial like this and see how you do. (Skip to part 4)
Take a look at the rclone tool - it can do do parallel uploads to S3 (and handles retries etc.). I'd be tempted to just use that rather than try reimplement it in Ruby - it's very reliable: https://rclone.org/
My feeling is using CoffeeScript should be opt-in, rather than opt-out. DHH to a degree is right, in that you can comment that line out of your config if you don't expect to use it.
But, in my opinion, what it more right is this perspective:
> Seems like commenting it out in the Gemfile might be the best of both worlds. Shows it is there and supported, but isn't the default.
Rails already has a few of these commented out lines in its config. It would make it easy to begin using CoffeeScript, for those few who want it.
I think the nerdrage is because an odd decision has been made on people's behalf, where now most of us will have to opt-out.
Duplicate of: Imagemagick: Convert to fixed height, proportional width
http://www.imagemagick.org/script/command-line-processing.php#geometry
xheight Height given, width automagically selected to preserve aspect ratio.
Converting arbitrary images from raster to vector format is kindof hard. There's software to do it, like Adobe Streamline, or AutoTrace.
Your best bet might be to install ImageMagick, and use Paperclip to act as an interface to that. Once you have that up and running, you can look into using a raster-to-vector conversion program.
Here's some documentation on the ImageMagick site on doing that: http://www.imagemagick.org/Usage/transform/#edge_vector
Mechanize is actually pretty easy to use - I wrote a lot of scrapers with it at my last job.
If the StackOverflow question in your post describes your actual problem, try this Stackoverflow answer which actually has an answer:
agent = Mechanize.new page = agent.get "http://google.com" node = page.search ".//p[@class='posted']" Mechanize::Page::Link.new(node, agent, page).click
I think this basically comes down to: you and your app developer need to sit together and debug the thing.
Ask him to change the server address to point to a version of your Rails application running on your local machine (connecting to that should work just fine from within the same wireless network once you tell your rails server to listen on all interface by starting the server with -b 0.0.0.0
). Alternatively, if you're e.g. not working from the same location, or your network blocks the access, you can use https://ngrok.com to give him a publicly accessible version of your local Rails server.
Next set breakpoints in the controller actions, models, etc. and step through the calls, checking results, making sure that data is as expected and records are actually saved.
If you centralize authentication you will always have a single point of failure. At edX we use OpenID Connect for our IDA/micro-service authentication. We are just starting to need inter-IDA communication, for which we are moving toward using JWT.
What about contributing to Diaspora, an existing open source social media server that is built on Rails?
Diaspora has a clean architecture, strong test culture and strict style policies - making it a good project for new developers.
https://diasporafoundation.org / https://github.com/diaspora/diaspora
This is a question I have never seen an answer to. People are always talking about best practices but are never able to point to an example open source project. Seeing and, more importantly, working with better code is a great way to get better.
You might check out GitLab. It is reasonably well tested and the code climate rating isn't bad, but you'll run across some bad habits as well.
I would highly recommend going through a basic SQL tutorial like SQLZOO or similar. This will really help you understand how relational databases work, and will give you a lot of insight on how to model your data.
http://sqlzoo.net/ is pretty good for getting your SQL basics down. It only takes a day to go through all the material; definitely worth the time.
The demand for Rails developers is such that you can probably land a Rails job knowing next to no actual SQL, but you should know it to actually be competent at that job, and relating questions about ActiveRecord where and includes and such to the actual SQL under the hood can be impressive in interview, too.
So let’s start with some terminology. It sounds like you’re trying to achieve SSO - that is, you log in once and you’re also authenticated in to several other apps.
You need to designate an app as the “identity provider” (IDP). It has the master list of users who should be able to authenticate, along with which other apps they should be allowed to use (aka scopes), and houses the login flow.
The other apps are known as “service providers” (SP). When a user turns up, the SP asks for a valid token that say who you are and what you should be allowed to do. If you don’t have a token, it can request a token on your behalf from the IDP, or redirect you there to log in. The SP makes fine-grained decisions about what you should be allowed to do eg view or update a specific record.
There are a couple of standards for how to set up communication between the IDP and the SPs, and I can’t say much more without getting in to the real details about how your apps are running. Read up on JWT, oAuth 2.0 and OpenId Connect. Auth0 is a paid IDP service that implements these protocols, but they also have really good docs about the protocols: https://auth0.com/docs/flows
Yep, getting away from gemified assets is an important step. You can include yarn-managed packages in sprockets's application.js. I just place jquery at the top. None of our packs have jquery dependencies, but if you do: https://webpack.js.org/configuration/externals/ to avoid double-loading issues.
Flask is definitely one of the simplest ways to do this, especially if you already know python. But why do you even need a web server? Why not just set up a cron job with a python script using requests? It would be as simple as having all of the host names in a txt file and iterating through them making sure you get a 200 status and send an email if it doesn't.
I'm just finishing up a rails app at the moment which uses bootstrap and bootstrap-material-design gems. It's not perfect, but it works for what I'm doing. There's also another framework called materialize which looks really nice. I wish I had used that at the beginning of my project.
other people have mentioned Hartl, it's a good as a starter resource, but seeing it has been a year for you and you are already building things, you made need to be sure you have your fundamentals down.
If you want detailed curriculum, and thorough, hands down you have free resources available:
https://www.theodinproject.com/tracks/full-stack-ruby-on-rails
You may benefit from the latter as it has very detailed material, full-stack, and video demos may be very helpful, they use correct terminology and articulation in them from what I have seen. I have also used Odin and it is also a great resource. I do feel I prefer app academy open at this stage, but I did start with Odin.
You don't have to pay for stuff, just find the best and go with it.
If you want to pay for real hardcore software fundamentals, $200 a month, checkout www.launchschool.com.
By the way, I'm not telling you to not do what others recommend here, those may be more suited for you and rails cast and other sites sounds pretty cool. But you have very good free resources above - doesn't make them any less better - and Launch School is quite detailed, difficult and is master-based. But keep in mind you won't even be doing rails execpt perhaps later in the backend if you choose to do a rails project, but they don't cover it. It's great for fundamentals.
I suggest looking at "uploading files using rails" then: http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm
The pdf reader itself doesn't really seem to be the problem in this case.
> That would result in the query being triggered everytime to get the count of all the orders.
Are you using redis? Use INCR? Something like:
Rails.cache.pool.with { |redis| redis.incr("order-count") }
Though I guess that could get out of sync though depending on your concurrency.
Really though this seems like premature optimization to me. Unless you're talking real Web Scale™ stuff here, I wouldn't stress too much about trying to save yourself the occasional COUNT()
query.
If you already have a redis service dependency, you can use it's INCR with EXPIRE to implement this easily. Just have a key like "ratelimit-#{current_user.id}" that tracks the number of requests. Then right after `INCR ratelimit-12345` you do `EXPIRE ratelimit-12345 100`. The result of the INCR command should be checked by your ruby code, and if it's above your limit per time window, you simply return a 429. This approach is actually described roughly in the redis docs
Yes, rails on windows kinda sucks :( you might want to look into something like vagrant, allowing you to work on windows like you're used to, but running your app in a headless Linux instance.
Getting a decent Rails environment up and running under Windows is absolutely excruciating. You're not going to be running Rails in production under Windows (unless you're insane), so there's no reason to do it in development.
One option to definitely look at is Vagrant. Most of my team used this until they all eventually just switched to OS X.
You don’t need JS to do this. And you’re going want it semantic so it’s accessible & useable via keyboard.
You need a label tag & a checkbox for each option. The label tag’s “for” attribute should be it’s checkbox’s “id” attribute. Style the label tag like a button, rounded corners, borders, etc. Then hide the checkbox input.
Bootstrap has another way to do this as well. This uses JS to set the state of the button but doesn’t change an input.
If you don't want to bundle Bootstrap with rest of your assets, just use CDN they have.
Look at the starter template: https://getbootstrap.com/docs/4.0/getting-started/introduction/#starter-template
If you want to use mixins/variables then use bootstrap-rubygem
(not bootstrap-sass
)
I think it might be your join statement. I think posgres wants something like .joins("JOIN balances ON (balances.account_id = accounts.id)")
I've never used groupdate
which looks helpful (especially for timezones), but you may be getting lost in the abstraction. Grouping by date boils down to something like this:
Rating.select('date(created_at) as date, COUNT(id) as count'). where('created_at > ?', Time.now - 1.month). group('date'). order('date')
Read up on your database's date/time functions and aggregate functions
Octopress is a simple blogging platform built on ruby. There's a simple rake task for generating new posts and it's flexible enough to use markdown or haml depending on your preferences.
This is what I use for my blog - static stuff, just like you're saying.
It's really great. You could conceivably host it on Github and point their domain to it. Github doesn't want you to do that of course (they want you to host a blog) - but you could definitely get away with it for some time.
These gems are a start. But the best way to validate an email is through double opt-in. That’s sending somebody a confirmation email.
It’s recommended by every email 3rd party since it protects your spam reputation. And it reduces valid emails that have been mistyped or harvested from a data breach.
I've had the exact issue with my Rails 5 app on heroku too. After weeks of searching, I found that the statement cache comes defaulted to 1000 in v5, not sure if it was lower in v4.
Lowering it to 200 in my database.yml fixed it for me. https://stackoverflow.com/questions/38513790/change-activerecord-statement-cache-default-rails
I'm dealing with the Stripe API and the best that I can come up with to pull all of the customers line_items is by using the Session Object. If you have an answer other than that, I'd love to hear it. ":^)
I don't have much experience with Capybara, but a quick google search yielded some promising Stack Overflow results.
https://stackoverflow.com/questions/10804897/how-to-fill-hidden-field-with-capybara
https://stackoverflow.com/questions/14117147/capybara-testing-value-of-hidden-field
If you're using postgres an easy way would be to set the id column to be a uuid and destroy the object when the api responds.
You could also build a deleted_at column into the model's table and use scopes to prevent the model from being accessed in the default scope (The only way to find the model in rails would be to use #unscoped) See This Stack Overflow or if you want to see how a library would do it see This gem called Paranoia
Ezra's 11/3/2005 blog on the Yakima Herald Republic's Rails deployment..
All that year of 2005 I recall reading the mailing lists and seeing Ezra posting Ruby tips.. Again it caught my attention because Ezra was posting from Yakima here in Washington State.
On AWS you can generate free SSL certificates that will automatically renew, the only catch being they only work on AWS services (you can't export a copy to put on a third-party server). See AWS Certificate Manager.
I'm not sure how to do this on the free Heroku dynos, but I'm sure I found some articles on how to do this before they released their paid-dynos-only Let's Encrypt integration - unfortunately I can't find them now, sorry.
my impression, though is that like carrierwave, paperclip first uploads files to the app and then to amazon.
The problem is that I am going to be uploading fairly large files, and heroku has a 30 second timeout.
I just came across ungulate, which seems to take a very different approach, pushing all the work off on to amazon servers.
what is the output of free
? Do you not have swap configured?
take a look at this howto to understand how to add swap to the server if you have not already. Depending on what you are running on that server if you do not have swap the os will just kill procs that try to allocate over the remaining memory. Once you add swap, the OS will instead will swap out to that swap area some ram contents to allow you to allocate more for a process temporarily. Your machines should always have something like 2*ram configured as swap (more or less dpending on your use case -- but 2*x is safe.
Heroku is definitely the easiest way to deploy a rails app that I'm aware of. They have a free tier that will probably suffice during development, but it's on the more expensive side when you move to production.
If you're feeling a little more adventerous (and looking to save costs) then Digital Ocean is a great provider where you can just get a linux box to do whatever you want with. If you're unfamiliar with setting up rails for production they have quite a few community contributed guides and even a one click install.
In my opinion it's really worth learning to set up a linux box yourself because those skill can translate to almost any provider. But I still go to Heroku when I want to deploy toy apps because it's so easy!
Webhooks are your friend!
If you're managing something like subscriptions, you can create an endpoint in your app to listen for certain events like when a monthly bill is paid successfully (update the expiration date in your database) or fails (suspend the subscription in your database and notify the user).
The specific actions will be unique to your application, but I typically handle these through a Webhooks controller that responds only to the events that I need. You can also configure your Webhooks through Stripe's admin dashboard to only send the events you're interested in recording.
I always recommend The Odin Project, the curriculum really covers the full stack a web developer needs and will force you to work on your own computer, create your own projects, work with git. You need to think, but also you will really learn. Following tutorials can be dangerous, there is a very really thing called Tutorial hell.
There is also a very helpful discord community along with it.
https://www.theodinproject.com
It actually points you to many other helpful resources and really does not try to be the best content for everything, if there are great resources out there.
Really can't recommend this enough. This is the way.
You need to add a line to your login script (.bashrc file IIRC). The "fix" is probably the line that is supposed to be run every time you login.
However, I'll second /u/fp4 that it would be better to wipe out everything you did with rvm and use rbenv (with ruby-build). Or if you want it to just work without any hassle, just do sudo aptitude install ruby2.0
. It's not the latest version of ruby but at least you can get started coding with no fuss. Or you can get the latest versions of ruby through apt using the brightbox ppa:
sudo su -c 'add-apt-repository ppa:brightbox/ruby-ng && aptitude update && aptitude install ruby2.3'
I really dig the CodeAcademy 'Learn Rails' path. They have an online IDE as part of the course, and it walks you through the app creation.
I also like that they don't just tell you what to type... they might give you a migration file and ask you to complete it for a certain model, and you have to figure out how.
http://www.codecademy.com/learn/learn-rails
I felt like I was becoming an expert copier by following online tutorials rather than actually have to think about what I was typing.
You can choose the default Ruby on Rails on 14.04 droplet which already has Ruby, Nginx, Unicorn and Postgress installed. The database connection information is then displayed at the top when you connect to the droplet with SSH. You can follow this tutorial to help you along the way: https://www.digitalocean.com/community/tutorials/how-to-use-the-1-click-ruby-on-rails-on-ubuntu-14-04-image .