Skip to content

Commit 25e6820

Browse files
authored
Update README.md
1 parent 78914db commit 25e6820

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

RoR/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,104 @@
1+
2+
# Rails Debugging and Development Guide
3+
4+
## Development Tools and URLs
5+
6+
### Rails Development URLs
7+
8+
- **Routes Information**: `http://localhost:3000/rails/info/routes`
9+
10+
- Lists all available routes in your Rails application
11+
- Helpful for debugging routing issues
12+
- Shows controller actions and their corresponding URLs
13+
14+
- **Letter Opener**: `http://localhost:3000/letter_opener`
15+
- Preview emails in the browser instead of sending them
16+
- Great for testing email functionality locally
17+
18+
## Debugging Tools
19+
20+
### Rails Console
21+
22+
```bash
23+
rails c # or rails console
24+
```
25+
26+
- Interactive console to test Ruby code
27+
- Direct database access
28+
- Test model associations
29+
- Execute arbitrary Ruby code in your app's environment
30+
31+
### Rails Logger
32+
33+
```ruby
34+
Rails.logger.debug "Debug: @user = #{@user}"
35+
```
36+
37+
Other log levels:
38+
39+
```ruby
40+
Rails.logger.info "Info message"
41+
Rails.logger.warn "Warning message"
42+
Rails.logger.error "Error message"
43+
Rails.logger.fatal "Fatal message"
44+
```
45+
46+
## Database Commands
47+
48+
### Seeding Data
49+
50+
```bash
51+
rails db:seed:development:users # Seed development user data
52+
rails db:seed # Run all seed files
53+
```
54+
55+
Other useful database commands:
56+
57+
```bash
58+
rails db:migrate # Run pending migrations
59+
rails db:rollback # Rollback last migration
60+
rails db:reset # Drop & recreate database
61+
rails db:setup # Create database, load schema, and initialize with seed data
62+
```
63+
64+
## Code Quality Tools
65+
66+
### RuboCop
67+
68+
Basic usage:
69+
70+
```bash
71+
rubocop # Check code style
72+
```
73+
74+
Auto-correction options:
75+
76+
```bash
77+
rubocop -a # Safe auto-corrections (--auto-correct)
78+
rubocop -A # Safe + unsafe auto-corrections (--auto-correct-all)
79+
```
80+
81+
Common RuboCop flags:
82+
83+
```bash
84+
rubocop --only Style/StringLiterals # Check specific cop
85+
rubocop --format html > rubocop.html # Generate HTML report
86+
rubocop --auto-gen-config # Generate .rubocop_todo.yml
87+
```
88+
89+
### Performance Monitoring
90+
91+
```ruby
92+
# Add at the start of a block you want to measure
93+
start_time = Time.now
94+
95+
# Add at the end of the block
96+
end_time = Time.now
97+
Rails.logger.debug "Operation took #{end_time - start_time} seconds"
98+
```
99+
100+
----------------------------
101+
1102
# Initialization
2103

3104
For macOS

0 commit comments

Comments
 (0)